From ad29bea7b03f46aa697e6623bdf7a17347ace651 Mon Sep 17 00:00:00 2001 From: Sebastiaan ten Pas Date: Tue, 17 Mar 2020 16:10:14 +0000 Subject: [PATCH] fix: replace createFactory usages with createElement --- src/createReducerContext.ts | 4 ++-- src/createStateContext.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/createReducerContext.ts b/src/createReducerContext.ts index fab55fe7..35862e18 100644 --- a/src/createReducerContext.ts +++ b/src/createReducerContext.ts @@ -1,11 +1,11 @@ -import { createFactory, createContext, useContext, useReducer } from 'react'; +import { createElement, createContext, useContext, useReducer } from 'react'; const createReducerContext = >( reducer: R, defaultInitialState: React.ReducerState ) => { const context = createContext<[React.ReducerState, React.Dispatch>] | undefined>(undefined); - const providerFactory = createFactory(context.Provider); + const providerFactory = (props, children) => createElement(context.Provider, props, children); const ReducerProvider: React.FC<{ initialState?: React.ReducerState }> = ({ children, initialState }) => { const state = useReducer(reducer, initialState !== undefined ? initialState : defaultInitialState); diff --git a/src/createStateContext.ts b/src/createStateContext.ts index 57333b1a..149d6f9d 100644 --- a/src/createStateContext.ts +++ b/src/createStateContext.ts @@ -1,8 +1,8 @@ -import { createFactory, createContext, useContext, useState } from 'react'; +import { createElement, createContext, useContext, useState } from 'react'; const createStateContext = (defaultInitialValue: T) => { const context = createContext<[T, React.Dispatch>] | undefined>(undefined); - const providerFactory = createFactory(context.Provider); + const providerFactory = (props, children) => createElement(context.Provider, props, children); const StateProvider: React.FC<{ initialValue?: T }> = ({ children, initialValue }) => { const state = useState(initialValue !== undefined ? initialValue : defaultInitialValue);