Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Do not mutate initial state#614

Merged
jorgebucaran merged 1 commit into
jorgebucaran:masterfrom
frenzzy:immutable-initial-state
Feb 22, 2018
Merged

Do not mutate initial state#614
jorgebucaran merged 1 commit into
jorgebucaran:masterfrom
frenzzy:immutable-initial-state

Conversation

@frenzzy

@frenzzy frenzzy commented Feb 21, 2018

Copy link
Copy Markdown
Contributor

Currently:

const initialState = { // immutable
  nested: { // mutable
    some: 'value'
  }
}
const actions = {
  nested: {
    example: {
      action() {}
    }
  }
}

console.log(initialState.nested.example) // => undefined
app(initialState, actions, () => {})
console.log(initialState.nested.example) // => {}

Demo: https://codepen.io/frenzzy/pen/NyMzGr?editors=0010

@jorgebucaran jorgebucaran left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perfect! Thanks, @frenzzy. 👍

@jorgebucaran jorgebucaran merged commit a7cf419 into jorgebucaran:master Feb 22, 2018
@frenzzy frenzzy deleted the immutable-initial-state branch February 22, 2018 11:20
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

Successfully merging this pull request may close these issues.

2 participants