Skip to content

Commit

Permalink
fix: replace createFactory usages with createElement
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirzono committed Mar 17, 2020
1 parent af66607 commit ad29bea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/createReducerContext.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createFactory, createContext, useContext, useReducer } from 'react';
import { createElement, createContext, useContext, useReducer } from 'react';

const createReducerContext = <R extends React.Reducer<any, any>>(
reducer: R,
defaultInitialState: React.ReducerState<R>
) => {
const context = createContext<[React.ReducerState<R>, React.Dispatch<React.ReducerAction<R>>] | undefined>(undefined);
const providerFactory = createFactory(context.Provider);
const providerFactory = (props, children) => createElement(context.Provider, props, children);

const ReducerProvider: React.FC<{ initialState?: React.ReducerState<R> }> = ({ children, initialState }) => {
const state = useReducer<R>(reducer, initialState !== undefined ? initialState : defaultInitialState);
Expand Down
4 changes: 2 additions & 2 deletions src/createStateContext.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createFactory, createContext, useContext, useState } from 'react';
import { createElement, createContext, useContext, useState } from 'react';

const createStateContext = <T>(defaultInitialValue: T) => {
const context = createContext<[T, React.Dispatch<React.SetStateAction<T>>] | 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<T>(initialValue !== undefined ? initialValue : defaultInitialValue);
Expand Down

0 comments on commit ad29bea

Please sign in to comment.