one-provider-per-component
This fails the run. Where it is wrong about your code, // ramonda-check-ignore <reason> on the line says so, and the reason is printed on every run.
Reported when one component mounts two Providers of the same context, which core refuses at runtime.
The framework reports the same fault while running, as RMD056 — but only once the line actually runs. This is the same fault proved from the source instead.
A component publishes a context on ONE object, so the second Provider replaces the first and every descendant reads the second whichever part of the tree it is in — while this component can still read both through its own hooks, which is what makes it invisible from here.
Give each one its own component and the subtree it is for. A component that renders
this.props.children scopes its context to what is inside it, so two of them side by side are
two independent scopes and a consumer in each finds its own with nothing passed down:
class Scope extends Component<{ theme: string; children?: RamondaNode }> {
provider = this.use(ThemeProvider, () => ({ theme: this.props.theme }));
render() { return this.props.children; }
}
If the two values are for different purposes, they are two contexts — call createContext
twice. Splitting the keys between two Providers is not a way out: a Provider takes its options
whole, so the second replaces the channel and the first half falls back to the default.
NESTING is untouched. A Provider on a descendant shadows the one above it for its own branch, which is ordinary — only two on the SAME component are refused.
A BASE CLASS is the same component. Its fields initialise first, on the same instance, so a Provider inherited from a base and another mounted here are two on one object — move one of them onto a component of its own rather than up or down the chain.
Next
- All rules — the other checks this one runs beside.
- Checking your app — how to run it, and what it proves.