xrutayisire / react-js-cron

A React cron editor built with antd
https://xrutayisire.github.io/react-js-cron/?path=/docs/reactjs-cron--demo
MIT License
238 stars 105 forks source link

When I add the dropdownsConfig property to the Cron component, it starts to re-render and goes into an infinite loop #67

Open nesathanozturk opened 4 months ago

nesathanozturk commented 4 months ago

Describe the bug When I add the dropdownsConfig property to the Cron component, it starts to re-render and goes into an infinite loop.

To Reproduce Steps to reproduce the behavior:

  1. Add dropdownsConfig property to Cron component.
  2. Choose month and select any value at "every day of the month" dropdown. Also add a console.log into your component.
  3. When selected a value, it starts to re-render.
  4. You can see the infinite console.log loop in your browser.

Expected behavior When I add the dropdownsConfig property to the Cron component, it shouldn't go into an infinite loop.

Screenshots

ss2 ss1

Versions (please complete the following information):

xrutayisire commented 4 months ago

Hi,

I don't know how nobody reported this. I definitely think there is a bug on this particular prop. I don't have time right now to fix it. If you can debug and create a PR it's perfect 🙌

In the meantime, I recommend everyone, not to use this prop until a fix is made.

nesathanozturk commented 2 weeks ago

@xrutayisire Hi again. I added the following control into the setValue function and it fixed the re-render problem. Now, i can use the dropdrownsConfig property with setValue function. Maybe it might be useful for you to solve this problem.

  setValue={(newValue: string) => {
     if (newValue !== values.cronValue) {
                dispatchValues({
                    type: 'set_values',
                    value: newValue,
                })
                handleCronChange(newValue)
            }
    }}