Performance optimization tips for react-resize-detector
masterTo ensure high performance when using the library, follow these best practices:
- Limit dimension tracking: Use
handleWidth: falseorhandleHeight: falseif you only need to monitor one dimension. - Skip initial mount: Use
skipOnMount: trueif you do not need the initial measurements immediately upon mounting. - Rate limit updates: Use
refreshMode: 'debounce'or'throttle'with arefreshRatefor expensive resize handlers (e.g., redrawing charts). - Use
disableRerender: If you only need to perform side effects (like updating external state or logging) without triggering a React component re-render, setdisableRerender: trueand use theonResizecallback. - Specify box model: Use
observerOptions: { box: 'border-box' }for more consistent and accurate measurements.