-4

I am playing around with immer.js. Immer.js lock obejct after giving new instance. Is it ok to use this locked object as global state?

windows.initialState = {a: 'a'};
const nextState = produce(initialState , draftState => {
    draftState.a = 'b',
  });

windows.initialState = nextState;

1 Answers1

1

Yes, you can assign and keep the frozen object to the global state. As long as your global object(initial state) is not declared as const. So, Nothing wrongs with this code.

Mohammad Quanit
  • 120
  • 2
  • 14