Module ReactSource

The React library

Sourcetype domRef
Sourcetype 'value ref = {
  1. mutable current : 'value;
}
Sourcemodule Ref : sig ... end
Sourceval createRef : unit -> 'a option ref
Sourceval useRef : 'a -> 'a ref
Sourceval forwardRef : (unit -> 'a) -> 'a
Sourcemodule Event : sig ... end
Sourcemodule JSX : sig ... end

All of those types are used by the server-reason-react.ppx internally to represent valid React code from the server. It currently different from reason-react-ppx due to a need for knowing the types since ReactDOM needs to render differently depending on the type.

Sourcetype error = {
  1. message : string;
  2. stack : Yojson.Basic.t;
  3. env : string;
  4. digest : string;
}
Sourcemodule Model : sig ... end
Sourcetype ('props, 'return) componentLike = ?key:string -> 'props -> 'return
Sourceand element =
  1. | Lower_case_element of lower_case_element
  2. | Upper_case_component of string * unit -> element
  3. | Async_component of string * unit -> element Lwt.t
  4. | Client_component of {
    1. key : string option;
    2. props : client_props;
    3. client : element;
    4. import_module : string;
    5. import_name : string;
    }
  5. | List of element list
  6. | Array of element array
  7. | Text of string
  8. | Int of int
  9. | Float of float
  10. | Static of {
    1. prerendered : string;
    2. original : element;
    }
  11. | Writer of {
    1. emit : Buffer.t -> separators:bool -> unit;
    2. original : unit -> element;
    }
    (*

    Subtree with static skeleton + dynamic string/int/float/element holes. emit writes directly into the caller's buffer, avoiding the intermediate buffer + Buffer.contents allocation that a Static wrapping would require.

    separators tells the emit function whether adjacent text nodes must be delimited with an <!-- --> comment, matching react-dom: renderToString needs the delimiters so hydration can split merged text nodes, renderToStaticMarkup must not emit them.

    original is a thunk that rebuilds the variant-tree form on-demand for cloneElement / RSC consumers. Same name as Static.original for symmetry; this variant's version is lazy. Emitted by the PPX for the Needs_string_concat and Needs_buffer analysis tiers.

    *)
  12. | Fragment of element
  13. | Empty
  14. | Provider of {
    1. children : element;
    2. push : unit -> unit -> unit;
    3. async_key : Obj.t Lwt.key;
    4. async_value : Obj.t;
    }
  15. | Consumer of element
  16. | Suspense of {
    1. key : string option;
    2. children : element;
    3. fallback : element option;
    }
Sourceand lower_case_element = {
  1. key : string option;
  2. tag : string;
  3. attributes : JSX.prop list;
  4. children : element list;
}
Sourceand client_props = (string * element Model.t) list
Sourceand model_value = element Model.t
Sourceexception Invalid_children of string
Sourcemodule Fragment : sig ... end
Sourceval createElement : string -> JSX.prop list -> element list -> element
Sourceval createElementWithKey : ?key:string -> string -> JSX.prop list -> element list -> element
Sourceval fragment : element -> element
Sourceval cloneElement : element -> JSX.prop list -> element
Sourceval string : string -> element
Sourceval null : element
Sourceval int : int -> element
Sourceval float : float -> element
Sourceval array : element array -> element
Sourceval list : element list -> element
Sourcetype 'a provider = value:'a -> children:element -> unit -> element
Sourcemodule Context : sig ... end
Sourceval createContext : 'a -> 'a Context.t
Sourcemodule Suspense : sig ... end
Sourcemodule Cache : sig ... end
Sourcetype any_promise =
  1. | Any_promise : 'a Lwt.t -> any_promise
Sourceexception Suspend of any_promise

Signatures match reason-react. On the server there's no re-render, so memoization is a no-op: the component is returned unchanged and the compare function is ignored.

Sourceval memo : 'component -> 'component
Sourceval memoCustomCompareProps : 'component -> ('props -> 'props -> bool) -> 'component
Sourceval cache : ('a -> 'b) -> 'a -> 'b
Sourceval useContext : 'a Context.t -> 'a
Sourceval useState : (unit -> 'state) -> 'state * (('state -> 'state) -> unit)
Sourceval useMemo : (unit -> 'a) -> 'a
Sourceval useMemo0 : (unit -> 'a) -> 'a
Sourceval useMemo1 : (unit -> 'a) -> 'b -> 'a
Sourceval useMemo2 : (unit -> 'a) -> 'b -> 'a
Sourceval useMemo3 : (unit -> 'a) -> 'b -> 'a
Sourceval useMemo4 : (unit -> 'a) -> 'b -> 'a
Sourceval useMemo5 : (unit -> 'a) -> 'b -> 'a
Sourceval useMemo6 : (unit -> 'a) -> 'b -> 'a
Sourceval useCallback : 'a -> 'a
Sourceval useCallback0 : 'a -> 'a
Sourceval useCallback1 : 'a -> 'b -> 'a
Sourceval useCallback2 : 'a -> 'b -> 'a
Sourceval useCallback3 : 'a -> 'b -> 'a
Sourceval useCallback4 : 'a -> 'b -> 'a
Sourceval useCallback5 : 'a -> 'b -> 'a
Sourceval useCallback6 : 'a -> 'b -> 'a
Sourcemodule Tree_context : sig ... end
Sourceval current_tree_context : Tree_context.t ref

Rendering hook context — called by the renderer before/after rendering each function component.

Process-global: two async renders must not be in flight concurrently in one process, or their useId state corrupts each other at Lwt yields.

Sourceval reset_component_id_state : Tree_context.t -> unit
Sourceval check_did_render_id_hook : unit -> bool
Sourceval reset_id_rendering : ?prefix:string -> unit -> unit
Sourceval useId : unit -> string

Generates a stable id for the current render.

Relies on process-global state (current_tree_context et al.): only one async render may be in flight per process, otherwise concurrent renders interleave at Lwt yields and produce hydration mismatches.

Sourcetype ('input, 'output) callback = 'input -> 'output
Sourceval useSyncExternalStore : subscribe:((unit -> unit) -> (unit, unit) callback) -> getSnapshot:(unit -> 'snapshot) -> 'snapshot
  • deprecated Use useSyncExternalStoreWithServer instead
Sourceval useSyncExternalStoreWithServer : subscribe:((unit -> unit) -> (unit, unit) callback) -> getSnapshot:(unit -> 'snapshot) -> getServerSnapshot:(unit -> 'snapshot) -> 'snapshot
Sourceval useReducer : ('state -> 'action -> 'state) -> 'state -> 'state * ('action -> unit)
Sourceval useReducerWithMapState : ('state -> 'action -> 'initialState) -> 'initialState -> ('initialState -> 'state) -> 'state * ('action -> unit)
Sourceval useEffect : (unit -> (unit -> unit) option) -> unit
Sourceval useEffect0 : (unit -> (unit -> unit) option) -> unit
Sourceval useEffect1 : (unit -> (unit -> unit) option) -> 'dependency array -> unit
Sourceval useEffect2 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2) -> unit
Sourceval useEffect3 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2 * 'dependency3) -> unit
Sourceval useEffect4 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2 * 'dependency3 * 'dependency4) -> unit
Sourceval useEffect5 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2 * 'dependency3 * 'dependency4 * 'dependency5) -> unit
Sourceval useEffect6 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2 * 'dependency3 * 'dependency4 * 'dependency5 * 'dependency6) -> unit
Sourceval useLayoutEffect0 : (unit -> (unit -> unit) option) -> unit
Sourceval useLayoutEffect1 : (unit -> (unit -> unit) option) -> 'dependency array -> unit
Sourceval useLayoutEffect2 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2) -> unit
Sourceval useLayoutEffect3 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2 * 'dependency3) -> unit
Sourceval useLayoutEffect4 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2 * 'dependency3 * 'dependency4) -> unit
Sourceval useLayoutEffect5 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2 * 'dependency3 * 'dependency4 * 'dependency5) -> unit
Sourceval useLayoutEffect6 : (unit -> (unit -> unit) option) -> ('dependency1 * 'dependency2 * 'dependency3 * 'dependency4 * 'dependency5 * 'dependency6) -> unit
Sourceval setDisplayName : 'component -> string -> unit
Sourcemodule Children : sig ... end
Sourceval suspend : 'a Lwt.t -> unit
Sourcemodule Experimental : sig ... end
Sourceval useTransition : unit -> bool * ((unit -> unit) -> unit)
Sourceval useDebugValue : 'value -> ?format:('value -> string) -> unit
Sourceval useDeferredValue : 'value -> 'value