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

Controlled component #3

Open
janbaykara opened this issue Aug 16, 2018 · 4 comments
Open

Controlled component #3

janbaykara opened this issue Aug 16, 2018 · 4 comments

Comments

@janbaykara
Copy link

janbaykara commented Aug 16, 2018

Is there a way to set the 'open' element by key as a prop, so Grid can be used as a controlled, stateless component? You could use this to, say, synchronise the open state with a router system.

<Grid
   {...props}
   openKey={1}
/>
@drcmda
Copy link
Owner

drcmda commented Aug 16, 2018

@janbaykara That would be easy to add. Do you think driving it by index (0..n) and undefined (all close) should be enough? Also, should children then receive the toggle function? I suppose no ...

@janbaykara
Copy link
Author

janbaykara commented Aug 17, 2018

@drcmda Driving it by index could work, sure, especially given that we're just providing arrays and key accessors ourselves. toggle in controlled mode wouldn't have an effect on the openIndex in any case, I suppose.

Could supply a console warning when calling toggle and openIndex is not undefined, but we'd need to reconcile situations where toggle is called when openIndex is undefined, and then the openIndex prop is set to a value - which you'd expect to override the internal state.

@didiyakovleva
Copy link

didiyakovleva commented Nov 13, 2018

@drcmda Hey, what is the status of this? I am trying to synchronise the open state with a router and navigate to the grid with the cell expanded with key parsed from the url. Is it possible to trigger specific cell to be opened without click event? Thanks

@drcmda
Copy link
Owner

drcmda commented Nov 13, 2018

Could i interest you in making a PR? I'd guide you through the react-spring update as well.

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

3 participants