Code Monkey home page Code Monkey logo

Comments (5)

JanMesaric avatar JanMesaric commented on September 2, 2024

Same here, it has to do with re-rendering. If you try to zoom in you will now be able to stop getting that error and everything runs normal again. Looking for a workaround

from react-calendar-timeline.

KatSick avatar KatSick commented on September 2, 2024

@janckk so i should reduce re-rending counts?

from react-calendar-timeline.

JanMesaric avatar JanMesaric commented on September 2, 2024

Haven't found a solution yet. But if I zoom in and out the rerendering happens. Because if I push the new prop to the timeline I don't see immediate result. For example: I push another item and I only see it displayed after zoom in/out or when I drag other already existing items. If you add a new item you see it immediately rendered?

from react-calendar-timeline.

mariusandra avatar mariusandra commented on September 2, 2024

Hey, the timeline expects your items and groups arrays, and actually all other props as well, to be immutable. That means if you change something in items, you must pass it a new array with new items. Just adding something into the existing array will not work.

The sortedDimensionItems array is only updated when this condition is met:

nextProps.items !== this.props.items || nextProps.groups !== this.props.groups

That means, don't mutate your items array, pass in a new items array.

from react-calendar-timeline.

mariusandra avatar mariusandra commented on September 2, 2024

For some example code, I assume this is what you currently do:

var items = []
<Timeline items={items} />

items.push({id: 1})
items.push({id: 2})
items.push({id: 3})

But this is what you should be doing:

var items = []
<Timeline items={items} />

items = items.concat([{id: 1}])
items = items.concat([{id: 2}])
items = items.concat([{id: 3}])

This makes the timeline aware that the items array changed. Otherwise it's not smart (nor fast) enough to check every element inside items for changes.

from react-calendar-timeline.

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.