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

Add context typings #13

Merged
merged 1 commit into from Jun 4, 2018

Conversation

jpavon
Copy link
Contributor

@jpavon jpavon commented Jun 4, 2018

Related issue #5

@tsiq-swyx tsiq-swyx merged commit 326f63c into typescript-cheatsheets:master Jun 4, 2018
@tsiq-swyx
Copy link
Contributor

this is great! thank you! I might have to reorganize a bit, i'll do this after merge

@jpavon jpavon deleted the patch/context branch June 4, 2018 15:11
@slorber
Copy link
Collaborator

slorber commented Nov 12, 2018

note this implementation is not recommended for perf reasons, as creating a new store object on every render means that re-rendering the provider will make all the consumers re-render.

public render() {
    const store: ProviderStore = {
      state: this.state,
      update: this.update
    }

    return (
      <Context.Provider value={store}>
        {this.props.children}
      </Context.Provider>
    )
  }

This is one reason I built https://github.com/slorber/react-updatable-context, which is somehow an inferior version of Unstated

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.

None yet

3 participants