Closed tounsoo closed 3 years ago
@tounsoo Hello! is this happening in all components? or do you know about specific components with this behavior?
@OmarMorales71 Not sure what you mean. The Codesandbox example has only one component.
It's expected because setReferenceElement and setPopperElement are called after the initial render.
True, is there another way to use usePopper
so that we don't have to rely on useState, hopefully avoiding additional renders?
That's because we use ref callbacks, so any time one is set the component re-renders. This is needed because we need to know when a reference or popper element changes identity.
Reproduction demo
https://codesandbox.io/s/condescending-stallman-e81yy?file=/src/App.js
Steps to reproduce the problem
What is the expected behavior?
Seeing only one log of 'rendered'
What went wrong?
Looks like its rendering 3 times by default
Any other comments?
Is this normal behavior?
Packages versions