Coder Social home page Coder Social logo

Comments (3)

bvaughn avatar bvaughn commented on May 18, 2024 7

I have updated the docs to remove inline rendering functions! Hopefully this will avoid confusion in the future. πŸ˜…

from react-window.

bvaughn avatar bvaughn commented on May 18, 2024 5

This doesn't look like a "remount" – just a re-render of the <div>s. πŸ˜„

Let's use the React profiler to take a look at your sandbox:
sandbox1

The profiler shows us that each time the app re-renders, all of the list items re-render. This is because the list items are inline function components that get recreated each time your app renders:
screen shot 2018-09-18 at 7 36 23 am

This means that React will see them as a new type each time it renders, and so it will re-render them too.

Try moving the list item renders outside of your App render method, like so:
screen shot 2018-09-18 at 7 39 11 am
screen shot 2018-09-18 at 7 41 29 am

Now let's use the profiler to look at this forked sandbox where I did just that:
sandbox-2

The profiler shows us now that only your App component is re-rendering when you call forceUpdate()

Here's the source code for the forked sandbox:
https://codesandbox.io/s/n9z6lr0m2m

Maybe I should update the docs to avoid showing inline render methods. I tried to keep the docs brief so that they could be read easily but I can see how they might be misleading currently.

from react-window.

pasiba avatar pasiba commented on May 18, 2024

Thank you for explaining. I really appreciate it πŸ˜„

from react-window.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.