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

Object.freeze #5

Closed
hnordt opened this issue Sep 6, 2016 · 3 comments
Closed

Object.freeze #5

hnordt opened this issue Sep 6, 2016 · 3 comments
Assignees
Milestone

Comments

@hnordt
Copy link
Owner

hnordt commented Sep 6, 2016

State/props passed to children() shouldn't be mutated.

  render() {
    return this.props.children({ data: this.state.data, error: this.state.error })
  }

In this example data and error shouldn't mutated by the consumer.

To prevent mutation, I think that we can do something like this:

  render() {
    const frozenState = deepFreeze({ ...this.state })
    return this.props.children(frozenState)
  }
@hnordt hnordt added the question label Sep 6, 2016
@hnordt hnordt added this to the v1 milestone Sep 6, 2016
@hnordt hnordt self-assigned this Sep 6, 2016
@hnordt hnordt added discussion and removed question labels Sep 6, 2016
@hnordt hnordt changed the title Implement Object.freeze()? Object.freeze Oct 10, 2016
@hnordt
Copy link
Owner Author

hnordt commented Dec 2, 2016

I won't implement it for now.

@hnordt hnordt closed this as completed Dec 2, 2016
@gaearon
Copy link

gaearon commented Dec 6, 2016

Freezing is also somewhat slow, I'd only recommend it in development.

@hnordt
Copy link
Owner Author

hnordt commented Dec 6, 2016

Thank you @gaearon

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

No branches or pull requests

2 participants