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

feat: added helper methods to the context: Provider and Consumer #161

Merged
merged 1 commit into from
Jul 9, 2023

Conversation

ncpa0cpl
Copy link
Collaborator

@ncpa0cpl ncpa0cpl commented Jul 9, 2023

Added two helper methods to the Context object. A Provider and a Consumer are JSXTE Components that provide similar functionality to the React's Context.

Example

const myCtx  = defineContext<{foo: string}>;

const App = () => {
  return (
    <myCtx.Provider value={{ foo: "hello" }}>
      <myCtx.Consumer
        render={cv => <span>{cv.foo}</span>}
      />
    </myCtx.Provider>
  );
};

@ncpa0cpl ncpa0cpl merged commit f3462ec into master Jul 9, 2023
@ncpa0cpl ncpa0cpl deleted the feat/context-provide-consumer branch July 9, 2023 19:10
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.

1 participant