Using react-dot-fragment causes re-renders
sandeepdreddy opened this issue · comments
Using this package causes re-renders and as a result input fields lose focus
- Codepen with issue: https://codepen.io/anon/pen/BbYMYj
- Codepen using
React.Fragment
: https://codepen.io/anon/pen/WmMPBO
@sandeepdreddy thanks for the repro case! I think I fixed this in react-dot-fragment version 0.2.9. Could you try it?
To be clear, re-renders (as you're referring to them) are unavoidable. We're not actually replacing the dom elements themselves but we are moving elements around to convince React nothing changed.
I think the solution to your problem, though, is to just hold a reference to the previously focused element and restore focus when the render is finished: 7180abc
Does that seem ok? Or do you still have other problems?
here's a codepen with the new dependency version: https://codepen.io/anon/pen/drjJvy
I'll close the issue for now. Let me know if you think there's still a problem and we can re-open it.