value of the parent Context specified in contextType.
contextType
Static
If set, this.context will be set at runtime to the current value of the given Context.
this.context
type MyContext = numberconst Ctx = React.createContext<MyContext>(0)class Foo extends React.Component { static contextType = Ctx context!: React.ContextType<typeof Ctx> render () { return <>My context's value: {this.context}</>; }} Copy
type MyContext = numberconst Ctx = React.createContext<MyContext>(0)class Foo extends React.Component { static contextType = Ctx context!: React.ContextType<typeof Ctx> render () { return <>My context's value: {this.context}</>; }}
https://react.dev/reference/react/Component#static-contexttype
Private
Readonly
value of the parent Context specified in
contextType
.