UseRoot Causes double re-render
vinceprofeta opened this issue · 4 comments
vinceprofeta commented
When using useRoot
my App.js component renders twice on refresh. Using the higher order root resolves the issue.
Yomguithereal commented
Hello @vinceprofeta. Would you be able to open a PR to solve this issue?
vcardins commented
Any update on this?
Yomguithereal commented
No. Can you provide a minimal reproducible example so I can investigate?
georgehenderson commented
The issue seems to be centered around this effect. It causes the component tree to render when it sets the tree state inside of the effect. You essentially set state twice . https://github.com/Yomguithereal/baobab-react/blob/master/src/hooks.js#L31
I’m not entirely sure it’s needed using the tree as a singleton. My workaround was to just use a higher-order component for the root like Vince said above.