react-tree-walker icon indicating copy to clipboard operation
react-tree-walker copied to clipboard

issue with connect, outdated props when rendered

Open CosticaPuntaru opened this issue 7 years ago • 1 comments

here is a repo to reproduce the issue but i will try to summarise it here https://github.com/CosticaPuntaru/react-walk-tree--redux-bug

tl:dr; in order for nested component to render properly the component instance needs to recalculate props after the "visitor" function is run and before render is called.

what i understand from what happens: case: we have two components that want to lazy load data from server, one sibling of the other (i call them first and second), both of them are decorated with redux connect

running steps: reactWalkTree gets the App and walks it runs the connector component, binds the store props to the component props, then runs by "bootstrap" function, waits for it to finish and then runs the render,

the issue is that the render function is called with the props that were bind to the component before the "bootstrap" function was called. and having a if(!ready) return (<div>Loading</div>); will never give a change to the secondComponent.bootstrap to run and gather the data. thus not not getting the correct ssr,

hope this is clear enough,

CosticaPuntaru avatar Oct 22 '18 07:10 CosticaPuntaru

FWIW, I'm seeing the same issue with parent & child components

oyeanuj avatar Dec 23 '18 03:12 oyeanuj