Home > @uniformdev/mesh-sdk-react > useMeshLocation

useMeshLocation() function

Provides convenient access to the current Uniform Mesh location via React hook. Intended to be used within <MeshApp />.

There are three primary ways to invoke this hook: 1. Without any arguments, this hook will return the current location regardless of its type. The result will be a union of all possible locations you can discriminate between i.e. with an if statement on the type const location = useMeshLocation(); if (location.type === 'paramType') { // location is now known to be a paramType } 2. With a string argument, this hook will assert that the current location is the expected one and return the correct typings for that location. const location = useMeshLocation('settings'); 3. With an explicit generic to set the expected param type data or param type settings data. This is useful because (2) will return unknown as the value type for param types. const location = useMeshLocation();

You can also combine (2) and (3) to get both explicit value typing and assertion of the location.

Signature:

Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

expectedLocation

</td><td>

TLocationType

</td><td>

(Optional)

</td></tr> </tbody></table> Returns:

Omit<Extract<_uniformdev_mesh_sdk.AssetLibraryLocation<TLocationValue>, { type: TLocationType; }>)["setValue"]>[0]>; }