You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					32 lines
				
				679 B
			
		
		
			
		
	
	
					32 lines
				
				679 B
			| 
											3 years ago
										 | // @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>; |