![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
better-context
Advanced tools
Tiny React context wrapper for using contexts without the hassle
npm i better-context
or with yarn:
yarn add better-context
Create a context
const useCoolContext = betterContext()(({ state, provided }) => {
const counter = useState(0);
return {
foo: "bar",
counter: state(counter), // using the state wrapper is optional
output: "foo bar " + provided, // "foo bar baz"
};
});
Provide it at highest common ancestor
function App() {
return (
<useCoolContext.Provider provide="baz">
<Component />
</useCoolContext.Provider>
);
}
Consume the context
function Component() {
const { counter } = useCoolContext();
// counter.value (get) ✅
// counter.value = 123 ✅
// counter.value++ ✅
// counter.set(prev => prev + 1) ✅
return (
<>
<button onClick={() => counter.value--}>-</button>
{counter.value}
<button onClick={() => counter.value++}>+</button>
</>
);
}
It's that simple!
The reason for using currying to instantiate the better context is because TypeScript as of now does not support partial type argument inference. Thus, to circumvent this issue currying is utilized to allow the context return value to be inferred while the provided value can be given or left unused:
type Provided = {
foo: string;
bar: number;
};
const useTsContext = betterContext<Provided>()(({ provided }) => {
const counter = useState(0);
return `${provided.foo}: ${provided.bar}`;
});
/* ... */
<useTsContext.Provider
provide={{
foo: "baz",
bar: 1337,
}}
>
...
</useTsContext.Provider>;
FAQs
Tiny React context wrapper for using contexts without the hassle
The npm package better-context receives a total of 1 weekly downloads. As such, better-context popularity was classified as not popular.
We found that better-context demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.