rfcs
rfcs copied to clipboard
RFC: Context should accept non-children props as value
This RFC proposes allowing React Context to accept non-children props as the provided value.
- Keeps
valuefor backward compatibility. - If no
valueis passed, all non-children props become the context value. - Excludes
childrenfrom injection. - Simplifies context usage and makes it consistent with normal prop-passing in React.
Example:
<MyContext foo={foo} bar={bar}>
<App />
</MyContext>
Consumer:
const { foo, bar } = useContext(MyContext);