Skip to content

Function: useView() ​

Call Signature ​

useView<V, R>(view, ref, options?): R extends null | undefined ? R : Readonly<(ViewSelection<V> extends Selection<ViewEntityWithTypename<V>> ? Mask<ViewEntityWithTypename<V>, { [K in string | number | symbol as K extends "__typename" ? never : K]?: DeferrableSelectionFieldValue<ViewEntityWithTypename<V>, K> } & object & SelectionViewSpread<ViewEntityWithTypename<V>> & object & ViewSelection<V>> : ViewEntityWithTypename<V>) & object>

Defined in: react-fate/src/useView.tsx:26

Resolves a reference against a view and subscribes to updates for that selection. Pass a client in the options to read outside the nearest provider's client.

Type Parameters ​

V ​

V extends View<any, any>

R ​

R extends Readonly<{ __typename: any; [ViewsTag]: Set<string>; id: string | number; }> | null | undefined

Parameters ​

view ​

V

ref ​

R

options? ​

Readonly<{ client?: FateClient<any, any, string> | null; }>

Returns ​

R extends null | undefined ? R : Readonly<(ViewSelection<V> extends Selection<ViewEntityWithTypename<V>> ? Mask<ViewEntityWithTypename<V>, { [K in string | number | symbol as K extends "__typename" ? never : K]?: DeferrableSelectionFieldValue<ViewEntityWithTypename<V>, K> } & object & SelectionViewSpread<ViewEntityWithTypename<V>> & object & ViewSelection<V>> : ViewEntityWithTypename<V>) & object>

Example ​

ts
const post = useView(PostView, postRef);

Call Signature ​

useView<V, R>(view, ref, options?): R extends null | undefined ? R : Readonly<(ViewSelection<V> extends Selection<ViewEntityWithTypename<V>> ? Mask<ViewEntityWithTypename<V>, { [K in string | number | symbol as K extends "__typename" ? never : K]?: DeferrableSelectionFieldValue<ViewEntityWithTypename<V>, K> } & object & SelectionViewSpread<ViewEntityWithTypename<V>> & object & ViewSelection<V>> : ViewEntityWithTypename<V>) & object>

Defined in: react-fate/src/useView.tsx:34

Resolves a reference against a view and subscribes to updates for that selection. Pass a client in the options to read outside the nearest provider's client.

Type Parameters ​

V ​

V extends View<any, any>

R ​

R extends Deferred<ViewRef<ViewEntityName<V>>> | null | undefined

Parameters ​

view ​

V

ref ​

R

options? ​

Readonly<{ client?: FateClient<any, any, string> | null; }>

Returns ​

R extends null | undefined ? R : Readonly<(ViewSelection<V> extends Selection<ViewEntityWithTypename<V>> ? Mask<ViewEntityWithTypename<V>, { [K in string | number | symbol as K extends "__typename" ? never : K]?: DeferrableSelectionFieldValue<ViewEntityWithTypename<V>, K> } & object & SelectionViewSpread<ViewEntityWithTypename<V>> & object & ViewSelection<V>> : ViewEntityWithTypename<V>) & object>

Example ​

ts
const post = useView(PostView, postRef);

Call Signature ​

useView<V>(view, ref, options?): Readonly<(ViewSelection<V> extends Selection<ViewEntityWithTypename<V>> ? Mask<ViewEntityWithTypename<V>, { [K in string | number | symbol as K extends "__typename" ? never : K]?: DeferrableSelectionFieldValue<ViewEntityWithTypename<V>, K> } & object & SelectionViewSpread<ViewEntityWithTypename<V>> & object & ViewSelection<V>> : ViewEntityWithTypename<V>) & object> | null | undefined

Defined in: react-fate/src/useView.tsx:42

Resolves a reference against a view and subscribes to updates for that selection. Pass a client in the options to read outside the nearest provider's client.

Type Parameters ​

V ​

V extends View<any, any>

Parameters ​

view ​

V

ref ​

ViewRef<ViewEntityName<V>> | Deferred<ViewRef<ViewEntityName<V>>> | null | undefined

options? ​

Readonly<{ client?: FateClient<any, any, string> | null; }>

Returns ​

Readonly<(ViewSelection<V> extends Selection<ViewEntityWithTypename<V>> ? Mask<ViewEntityWithTypename<V>, { [K in string | number | symbol as K extends "__typename" ? never : K]?: DeferrableSelectionFieldValue<ViewEntityWithTypename<V>, K> } & object & SelectionViewSpread<ViewEntityWithTypename<V>> & object & ViewSelection<V>> : ViewEntityWithTypename<V>) & object> | null | undefined

Example ​

ts
const post = useView(PostView, postRef);

Released under the MIT License