GoScrobble/web/node_modules/@hypnosphi/create-react-context/lib/index.js.flow

32 lines
679 B
Plaintext
Raw Normal View History

2022-04-25 02:47:15 +00:00
// @flow
import { Component, type Node } from 'react';
type RenderFn<T> = (value: T) => Node;
export type ProviderProps<T> = {
value: T,
children?: Node
};
export type ConsumerProps<T> = {
children: RenderFn<T> | [RenderFn<T>],
observedBits?: number
};
export type ConsumerState<T> = {
value: T
};
export type Provider<T> = Component<ProviderProps<T>>;
export type Consumer<T> = Component<ConsumerProps<T>, ConsumerState<T>>;
export type Context<T> = {
Provider: Class<Provider<T>>,
Consumer: Class<Consumer<T>>
};
declare export default function createReactContext<T>(
defaultValue: T,
calculateChangedBits?: (prev: T, next: T) => number
): Context<T>;