@@ -30,7 +30,7 @@ and the `useIdleTimerContext` hook.
3030``` jsx
3131import { IdleTimerProvider , useIdleTimerContext } from ' react-idle-timer'
3232
33- export function Child (props ) => {
33+ export function Child () {
3434 const idleTimer = useIdleTimerContext ()
3535 return (
3636 < h1> {idleTimer .isIdle ()}< / h1>
@@ -203,7 +203,7 @@ To preserve types for your component's context, declare the type for the
203203component's context property.
204204
205205``` tsx
206- import { Component , ContextTypes } from ' react'
206+ import { Component , ContextType } from ' react'
207207import { IIdleTimerContext , IdleTimerContext } from ' react-idle-timer'
208208
209209export class Child extends Component <{}, {}> {
@@ -212,7 +212,7 @@ export class Child extends Component<{}, {}> {
212212 static contextType = IdleTimerContext
213213
214214 // Declare a type for context to preserve typescript types
215- declare context: ContextType <IIdleTimerContext >
215+ context! : ContextType <typeof IIdleTimerContext >
216216
217217 render () {
218218 return (
@@ -221,3 +221,10 @@ export class Child extends Component<{}, {}> {
221221 }
222222}
223223```
224+
225+ ## Examples
226+
227+ <Flex direction = ' column' mt = { 8 } >
228+ <CodeSandboxButton name = ' functional-context-provider-jz4y77' >Functional Context Provider</CodeSandboxButton >
229+ <CodeSandboxButton name = ' class-context-provider-mfujuj' >Class Context Provider</CodeSandboxButton >
230+ </Flex >
0 commit comments