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

Issue with rerender / componentWillReceiveProps #115

Open
mergebandit opened this issue Jan 2, 2018 · 0 comments
Open

Issue with rerender / componentWillReceiveProps #115

mergebandit opened this issue Jan 2, 2018 · 0 comments

Comments

@mergebandit
Copy link
Contributor

So I have a react-sortable-pane on a page with two items. On initialization, they are in order [0,1]. If I swap the order to [1,0], I fire off a dragStop event (orderChanged fires even if I haven't dropped, and that's not desirable). At dragStop I update the order in my app state. Everything is good.

Then I click a button which opens a right-sidebar. This causes my react-sortable-pane to reset to [0,1] order. Within componentWillReceiveProps, if I log this.props.children I see the children in the original order. If I log next.children, I see the children in the desired [1,0] order.

However, because componentWillReceiveProps is checking the arbitrary order prop, the setState({ panes: newPanes }) never gets called. If I manually call this.setSize() from within componentWillReceiveProps, the order of my panes are correct.

The problem I have is - I'm not sure how to fix this properly. Since the internals of pane order simply uses the index in an array, as opposed to something concrete like id, I can't just explicitly update the order.

Do I now have to manage the order myself and pass it in to the SortablePane component? That seems like duplicitous effort - I don't really care - I just want the order to be maintained across re-renders.

Do you have any other thoughts on this?

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

1 participant