In my project, I've come across a problem. It seems to be good relation to the close issue #362.
You guys provide a way to set modifiers like offset by using a callback to calculate whatever I want. Turns out this causes an endless loop. Presumably, it's caused by React rendering the component again as soon as the value comes out of the callback, causing React to think something changed and rerenders and there's the loop. This is just a hypothesis though.
Below I have a codesandbox example using typescript. If necessary I will do it in JS but I prefer TS
Hello popperjs Team!
In my project, I've come across a problem. It seems to be good relation to the close issue #362. You guys provide a way to set modifiers like offset by using a callback to calculate whatever I want. Turns out this causes an endless loop. Presumably, it's caused by React rendering the component again as soon as the value comes out of the callback, causing React to think something changed and rerenders and there's the loop. This is just a hypothesis though.
Below I have a codesandbox example using typescript. If necessary I will do it in JS but I prefer TS
Reproduction demo
https://codesandbox.io/s/popper-js-endless-loop-when-passing-modifier-with-callback-jz5sl?file=/src/App.tsx
Steps to reproduce the problem
What is the expected behavior?
To get the value out of the callback and set it as the value for the modifier.
What went wrong?
Endless loop probably caused by rerendering due to React thinking a value changed
Any other comments?
none
Packages versions