no-context-provider
🔧 This rule is automatically fixable by the --fix
CLI option.
Rule category
Restriction.
What it does
Disallows using <Context.Provider>
.
Why is this bad?
In React 19, you can render <Context>
as a provider instead of <Context.Provider>
.
Examples
Failing
const ThemeContext = createContext('');
function App({children}) {
return (
<ThemeContext.Provider value="light">
{children}
</ThemeContext>
);
}
Passing
const ThemeContext = createContext('');
function App({children}) {
return (
<ThemeContext value="dark">
{children}
</ThemeContext>
);
}