informed
informed copied to clipboard
useArrayFieldItem hook.
Hi, I want to window my form using react-window
, in order for this to work correctly, there is need to be either ArrayFieldItem
component or useArrayFieldItem
hook. so when react-window
wants to render the rows. I will give that component as a row.
right now, there is the ArrayField.Items
which maps the values by itself.
I dont follow. Can you create example issue in a code sandbox.
sorry I wasn't clear.
https://codesandbox.io/s/focused-rain-gq0be?file=/src/App.js
can you understand the problem from this code sandbox or I should make it more clear?
I'm making another code sandbox using react-window
instead of react-virtual
as it has less boilerplate code.
https://codesandbox.io/s/mystifying-feather-g1epx?file=/src/App.js
checkout this one.
I dont think this will work at all... array field is designed to need ArrayField.Items
( it does v important things intenrally. And even if i were to spend time refactoring that logic to live in hook it would not work because it requires all items be rendered at same time...
could you explain a bit why does it require all items to be rendered at the same time?
Because things like delete and swap depend on it ( especially delete ). If u delete array[9] then array[90] becomes array[89]. Array fields are the most complex thing in this library. It would take complete redesign of how they work to support not rendering all at the same time.
Also for various reasons. Initial values will NOT populate "values" until the field its associated with is rendered onto screen. This means if u rendered an array field with 100 items and never scrolled to 100. The values would never see half the items
When you look at array fields in a closed room it starts off seeming simple. Then u add the fact that fields are desinged to clean up after themselves on unrender + the concept of relevance where things become irrelevant or relevant depending on other things and the problem complexity goes way up.
Also for various reasons. Initial values will NOT populate "values" until the field its associated with is rendered onto screen. This means if u rendered an array field with 100 items and never scrolled to 100. The values would never see half the items
this one really isn't much of an issue, when the item is not rendered at all, that means the value hasn't been changed.
Because things like delete and swap depend on it ( especially delete ). If u delete array[9] then array[90] becomes array[89]. Array fields are the most complex thing in this library. It would take complete redesign of how they work to support not rendering all at the same time.
but yeah, this one is a big issue, swapping an item with the one that hasn't been rendered yet :x.
btw, could you fix the issue of keys getting changed after each re-render?