1 |
3a515b92
|
cagy
|
import * as React from 'react';
|
2 |
|
|
|
3 |
|
|
export default function createReactContext<T>(
|
4 |
|
|
defaultValue: T,
|
5 |
|
|
calculateChangedBits?: (prev: T, next: T) => number
|
6 |
|
|
): Context<T>;
|
7 |
|
|
|
8 |
|
|
type RenderFn<T> = (value: T) => React.ReactNode;
|
9 |
|
|
|
10 |
|
|
export type Context<T> = {
|
11 |
|
|
Provider: React.ComponentClass<ProviderProps<T>>;
|
12 |
|
|
Consumer: React.ComponentClass<ConsumerProps<T>>;
|
13 |
|
|
};
|
14 |
|
|
|
15 |
|
|
export type ProviderProps<T> = {
|
16 |
|
|
value: T;
|
17 |
|
|
children?: React.ReactNode;
|
18 |
|
|
observedBits?: any,
|
19 |
|
|
};
|
20 |
|
|
|
21 |
|
|
export type ConsumerProps<T> = {
|
22 |
|
|
children: RenderFn<T> | [RenderFn<T>];
|
23 |
|
|
observedBits?: number;
|
24 |
|
|
};
|