base-context-provider/example/src/TestContext.ts
2020-07-15 13:22:40 +07:00

34 lines
646 B
TypeScript

import React from 'react'
import BaseContextProvider, {
baseContextWrap,
baseUseContext,
baseWithContext
} from 'base-context-provider'
const Context = React.createContext({})
class TestContextProvider extends BaseContextProvider {
state = {
heat: 5,
punishmentLevel: 10
}
getContextReturnValue() {
return {
...this.state
}
}
getContext() {
return Context
}
}
export const useTestContext = baseUseContext(Context)
export const withTestContext = baseWithContext(Context, 'testContextProps')
export const wrapTestProvider = baseContextWrap(TestContextProvider)
export default TestContextProvider