Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe for locking initial state attribute ? #73

Closed
laurib opened this issue Oct 29, 2019 · 1 comment
Closed

Recipe for locking initial state attribute ? #73

laurib opened this issue Oct 29, 2019 · 1 comment

Comments

@laurib
Copy link

laurib commented Oct 29, 2019

I need to lock initial state attribute so that other developers are unable to overwrite it. How could i do that?

Lets say i have state like this:

defaultState = {
  isLoading: false,
  data: undefined,
  actions: {
    getData: ()
  }
}

Im using immer middleware and modified redux middleware that binds dispatch to every action on initialization .

When other devs want to reset state then they will do something like this:

case 'RESET':
  return defaultState;

But now dispatch is not bind to actions anymore

Locking is probably impossible? But can someone give me an hint how to write middleware or edit redux or immer middleware to check if 'actions' belongs to modified set attributes so i could bind dispatch again ?

Edit: Can close this issue. Solution was just not to keep actions in state.
const [useStore, actions ] = ....

@JeremyRH
Copy link
Contributor

Yeah I can close this. I'm glad you found a solution.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants