import React from 'react'; interface CreateContextFactoryOptions { defaultValue: Props; displayName: string; } export function createContextFactory( options: CreateContextFactoryOptions ) { const Context = React.createContext(options.defaultValue); Context.displayName = options.displayName; function useContext(): Props { return React.useContext(Context); } return { Context, useContext, }; }