Comments (3)
Layout effects are permitted when a component should re-size its contents before the browser paints. (This is done to avoid flickering/shifting.)
The main problem in the above screenshot is either (a) something in your code is triggering repeated renders+updates or (b) one or more of your components is doing too much work in render to be able to update quickly. Hard to tell which.
from react-virtualized-auto-sizer.
Layout effects are permitted when a component should re-size its contents before the browser paints.
@bvaughn
In this case aren't we triggering resize manually though? See: https://github.com/bvaughn/react-virtualized-auto-sizer/blob/master/src/AutoSizer.ts#L65C1-L66C1
The main problem in the above screenshot is either (a) something in your code is triggering repeated renders+updates or (b) one or more of your components is doing too much work in render to be able to update quickly
The screenshot is taken from codesanbox link's browser trace. https://codesandbox.io/p/sandbox/react-class-forked-5ffvgl?file=%2Fsrc%2Findex.js
All it does is:
- On Page load renders 10k components. Nothing virtualized.
- Each component implements a useEffect mount and cleanup.
- On click, Re-creates the class component which changes a text property in
componentDidMount
So there aren't repeated re-renders but paint is delayed here because it has a lot of slow side effects which have to be flushed synchronously because of the nested update. This can be quite terrible when you are unmounting a lot of components before mounting AutoSizer
from react-virtualized-auto-sizer.
I'm not sure what to say, except...don't re-render 10k components like that ๐ It's never going to be performant. Switching from a layout effect to a passive effect will not make a difference in many cases, (often something else will trigger a sync update which will cause React to also flush passive effects before proceeding). And even if that's not the case, it's still going to take a ton of CPU time.
Layout effects are for layout (resizing and positioning) which is exactly what this component does.
from react-virtualized-auto-sizer.
Related Issues (20)
- AutoSizer cannot be used as a JSX component typescript error HOT 4
- Reporting an integer size when the available space has decimals HOT 6
- "react-virtualized-auto-sizer ๆฐ็ๆฌ้ๅคๆธฒๆๅญ็ปไปถ๏ผๅ antd tabs ๅฒ็ช HOT 2
- API change in return type HOT 2
- Args is type `any` in latest version (1.0.18) HOT 23
- "Can't perform a React state update on an unmounted component" console error HOT 5
- 1.0.19 does not render anything HOT 1
- Is it possible to test AutoSizer-powered components in unit tests? HOT 8
- Types of disableHeight and disableWidth are incorrect HOT 6
- TypeScript: Incorrect typing of AutoSize height and width HOT 2
- Typings for conditional `disableHeight` and `disableWidth` HOT 2
- 'AutoSizer' cannot be used as a JSX component. HOT 1
- Is it possible to render content inside auto sizer callback on server? HOT 1
- AutoSizer not rendering initially with consistent height for fixed height components HOT 2
- Recurrence of old Resizer bug (Width/Height NaN for AutoSizer #150) HOT 4
- Version 1.0.22 is breaking all of our unit tests HOT 50
- Autosizer component does not accept any refs. HOT 1
- bailoutOnChildren causes remounts HOT 3
- Access the component height from outside the component to pass to itemSize HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-virtualized-auto-sizer.