Skip to content

Changing cron prop does not rerender component #20

@pmarshall111

Description

@pmarshall111

Describe the bug
I'm retrieving a cron from a database, and want to update the value of the cron to the value I get from the database.
When the response is retrieved from the database, the values of the component are not updated to the value of the new 'cron' prop.

Steps to reproduce
Demo here: https://codesandbox.io/s/material-ui-cron-stable-forked-5r89pd

Render component with:

const CronGenerator = (props) => {
    const [cron, setCron] = useState("30 9 * * 1")
    setTimeout(() => setCron("* * * * *"), 2000)


    return (
            <SchedulerRoot cron={cron}
                           setCron={updateCron}
                           setCronError={() => {}}
                           isAdmin={true}
                           />
    );
}

The component does not refresh to reflect the new value. I've included a picture to show that the props in React Component profiler are different to that actually displayed.

Screenshot from 2022-07-11 19-32-22

Note that I'm having to use the SchedulerRoot component due to an error when rendering just the <Scheduler /> component (image of the error below). However, note that in the demo linked at the top of this post, the same problem exists.

image

Solution (optional)

Additional context (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions