Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useArrayFieldItem hook. #366

Open
behzadmehrabi opened this issue Dec 13, 2021 · 11 comments
Open

useArrayFieldItem hook. #366

behzadmehrabi opened this issue Dec 13, 2021 · 11 comments

Comments

@behzadmehrabi
Copy link
Contributor

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.

@joepuzzo
Copy link
Collaborator

I dont follow. Can you create example issue in a code sandbox.

@behzadmehrabi
Copy link
Contributor Author

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?

@behzadmehrabi
Copy link
Contributor Author

I'm making another code sandbox using react-window instead of react-virtual as it has less boilerplate code.

@behzadmehrabi
Copy link
Contributor Author

@joepuzzo
Copy link
Collaborator

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...

@behzadmehrabi
Copy link
Contributor Author

could you explain a bit why does it require all items to be rendered at the same time?

@joepuzzo
Copy link
Collaborator

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.

@joepuzzo
Copy link
Collaborator

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

@joepuzzo
Copy link
Collaborator

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.

@behzadmehrabi
Copy link
Contributor Author

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.

@behzadmehrabi
Copy link
Contributor Author

btw, could you fix the issue of keys getting changed after each re-render?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants