question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting Start Date and End Date with onChange lead to infinit reRender

See original GitHub issue

Hello , First Thank you so much for the great Job , i tried to use the DateRangePicker and set startDate and EndDate from my redux, or even new Date() just for test , but it always fires the onChange on component mounting which lead to infinit reRender and Crash of the app, here what i did :

                <RangeDatePicker
                    startDate={new Date()}
                    endDate={null}
                    onChange={(startDate, endDate) => props.handleDatesChange(startDate, endDate)}
                    minDate={new Date()}
                    maxDate={new Date(2022, 0, 1)}
                    dateFormat="dddd D MMM"
                    monthFormat="MMM YYYY"
                    startDatePlaceholder={<Translate tKey="start_date" />}
                    endDatePlaceholder={<Translate tKey="end_date" />}
                    disabled={false}
                    className="my-own-class-name"
                    startWeekDay="monday"
                />

To reproduce the issue use startDate and endDate from redux store and the onChange dispatch an action

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
davidtrancommented, Aug 2, 2020

@kouloughli-hemza Hi, I have fixed this issue, please check.

0reactions
kouloughli-hemzacommented, Aug 2, 2020

@kouloughli-hemza Hi, I have fixed this issue, please check.

it works great now , thank you lot

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does setState in the body of the component cause an ...
In your case , You Have SetState in the body of the Component.. So it will rerender and Cause an Infinite Loop.. If...
Read more >
3 ways to cause an infinite loop in React - Alex Sidorenko
By executing a function before setting a handler, you update a state inside the render, which causes an infinite loop. State updates →...
Read more >
When does React re-render components? - Felix Gerschau
Scheduling a render means that this doesn't happen immediately. React will try to find the best moment for this. Changing the state means...
Read more >
How to solve too many re-renders error in ReactJS?
Use React shouldComponentUpdate: React shouldComponentUpdate is a method for optimizing performance, which tells React to stop re-rendering a ...
Read more >
Too many re-renders. React limits the number ... - Datainfinities
The above code will throw an error because we are trying to change the name setName("John"); in the main body of the component....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found