react-big-scheduler icon indicating copy to clipboard operation
react-big-scheduler copied to clipboard

Using mobx with react-big-scheduler

Open Bosseskompis opened this issue 5 years ago • 2 comments

Has anyone managed to use this library with Mobx? Changes don't cause rerender when schedulerData is an observable.

Bosseskompis avatar Jan 23 '20 13:01 Bosseskompis

I'm using a workaround for now where I am resetting the schedulerData with an empty object before updating it with the changes

Bosseskompis avatar Jan 24 '20 08:01 Bosseskompis

https://mobx.js.org/reactions.html

Example:

const [, updateState] = useState();
const forceUpdate = useCallback(() => updateState({}), []);

  React.useEffect(
    () =>
      autorun(() => {
        schedulerData.setDate(props.params.date_from);
        schedulerData.setEvents(props.events);
        forceUpdate();
      }),
    [],
  )

KotovaZ avatar Mar 25 '21 09:03 KotovaZ