Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (Context): Export entire OptimizelyContext object #27

Merged
merged 1 commit into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
import { createContext } from 'react'
import { ReactSDKClient } from './client'

export interface OptimizelyContext {
export interface OptimizelyContextInterface {
optimizely: ReactSDKClient | null,
isServerSide: boolean,
timeout: number | undefined,
}

const { Consumer, Provider } = createContext<OptimizelyContext>({
export const OptimizelyContext = createContext<OptimizelyContextInterface>({
optimizely: null,
isServerSide: false,
timeout: 0,
})

export const OptimizelyContextConsumer = Consumer
export const OptimizelyContextProvider = Provider
export const OptimizelyContextConsumer = OptimizelyContext.Consumer
export const OptimizelyContextProvider = OptimizelyContext.Provider
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { OptimizelyContextConsumer, OptimizelyContextProvider } from './Context'
export { OptimizelyContext, OptimizelyContextConsumer, OptimizelyContextProvider } from './Context'
export { OptimizelyProvider } from './Provider'
export { OptimizelyFeature } from './Feature'
export { withOptimizely, WithOptimizelyProps, WithoutOptimizelyProps } from './withOptimizely'
Expand Down
4 changes: 2 additions & 2 deletions src/withOptimizely.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import * as React from 'react'
import { Subtract } from 'utility-types'

import { OptimizelyContextConsumer, OptimizelyContext } from './Context'
import { OptimizelyContextConsumer, OptimizelyContextInterface } from './Context'
import { ReactSDKClient } from './client'
import { hoistStaticsAndForwardRefs } from './utils'

Expand Down Expand Up @@ -45,7 +45,7 @@ export function withOptimizely<P extends WithOptimizelyProps, R>(
// https://github.com/microsoft/TypeScript/issues/28884
return (
<OptimizelyContextConsumer>
{(value: OptimizelyContext) => (
{(value: OptimizelyContextInterface) => (
<Component
{...rest as P}
optimizelyReadyTimeout={value.timeout}
Expand Down