Giter VIP home page Giter VIP logo

Comments (6)

danawoodman avatar danawoodman commented on June 4, 2024

@davidgilbertson I'm sure you're a busy guy, but I'd love to figure out how to get things working well, attempting to add to a project :)

from react-recollect.

davidgilbertson avatar davidgilbertson commented on June 4, 2024

Sorry I've been slow replying, I'm knee deep in a new project.

In an original design I had it so that only one child component in an array of child components would update, but there's edge cases where that doesn't work, so the parent component will still go over all child components.

But when a component is defined as pure (with PureComponent or React.memo) the processing time is negligible.

Are your <ListItem /> components defined as pure? If not, do that, and React shouldn't be trying to re-render the component (which will cause those GET messages).

Let me know how that goes.

from react-recollect.

danawoodman avatar danawoodman commented on June 4, 2024

Makes sense, I will try that and report back!

from react-recollect.

danawoodman avatar danawoodman commented on June 4, 2024

Ok, so made all components in the tree PureComponent but I'm still getting a huge number of logs and slow rendering.

Is it normal to see so many log items with __RR__.debugOn()? Should I see a reduction in logs after making everything a PureComponent?

Should

from react-recollect.

davidgilbertson avatar davidgilbertson commented on June 4, 2024

I'm not sure what exactly is going up here. I've made a codesandbox to demonstrate what should be happening. https://codesandbox.io/s/myy44z7j38

Here, the <Product> component has lots of instances, and when you click the favourite button, it updates the store. When it does that, the parent component <Products> will be re-rendered, but because <Product> is pure, only the child components that have changed will be re-rendered (as you can see with the single console log being fired).

A few things to note that might be causing your situation:

  • When a parent component loops over some array to output all of the child components, it has to read something for each component, in this case just the ID:
        {filteredProducts && filteredProducts.map(product => (
          <Product key={product.id} product={product}/>
        ))}

So in the console that shows up as:

image

This is fine, because all the reads are happening on the parent (at the speed of JavaScript, nothing is rendering at this point). Only one of these will actually trigger a render of the child, the one where the property changed.

Also worth noting is that the console logging itself is slow, unfortunately. You can see in that sandbox the difference on/off makes (if you didn't know, in codesandbox you have to select the sandbox in the dropdown to get the console that relates your code)

image

Apologies for the slow reply!

from react-recollect.

davidgilbertson avatar davidgilbertson commented on June 4, 2024

I'm closing this now. FYI @danawoodman the logs to the console are now grouped (in v4.0.0), and I've added a note to the readme mentioning that this can effect performance.

from react-recollect.

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.