https://codesandbox.io/s/react-popper-v2x-issue-template-zck02?file=/src/index.js
Custom modifier modifies popper's width with the same width of input element. Also, without any infinitive loop.
Custom modifier goes to infinitive loop of defined function:
fn: ({state: { elements: { popper, reference }}}) => {
console.log("state", state);
popper.style.width = `${reference.offsetWidth}px`;
}
The same code worked with packages popperjs/core 2.4.0 and react 16.13.1. Code was tested in _Firefox (76.0.1)_ and _Brave (Version 1.8.96 Chromium: 81.0.4044.138)_ browser of _Linux Ubuntu 76.0.1_ OS.
This happens because you are defining the modifier in-line, so on each render its identity changes, and leads to the render loop.
You should define the modifier in a useMemo, or directly outside the component.
https://codesandbox.io/s/react-popper-v2x-issue-template-zfrf6?file=/src/index.js
It might be good to mention this in the documentation if not already there.
https://popper.js.org/react-popper/v2/faq/#why-i-get-render-loop-whenever-i-put-a-function-inside-the-popper-configuration
Most helpful comment
This happens because you are defining the modifier in-line, so on each render its identity changes, and leads to the render loop.
You should define the modifier in a
useMemo, or directly outside the component.https://codesandbox.io/s/react-popper-v2x-issue-template-zfrf6?file=/src/index.js