Context
Context
Overview
Installation
Required dependencies
This package relies on React hooks and thus requires version 16.3 or higher.
# npm
npm i --save @weser/context
# yarn
yarn add @weser/context
# pnpm
pnpm add @weser/context
Motivation
Context in React is a great way to pass data through the component tree.
But the provided API is not very ergonomic. This package provides a convenience helper function to create both a use context hook as well as a provider component.
Benefits
The same functionality that the built-in API provides, but in a more ergonomic way.
Additionally, ever context automatically accepts null
as a value to indicate "not set".
The hook will throw an error if you try to use the context without a provider.
© 2024-present Robin Weser. All Rights Reserved.