Skip to content

Function: createPlayRouterProvider()

API / @xmachines/play-solid-router / createPlayRouterProvider

function createPlayRouterProvider<TRouter>(BridgeCtor): <TActor>(props) => any;

Defined in: packages/play-solid-router/src/create-play-router-provider.tsx:69

Creates a Solid PlayRouterProvider component of one bridge class.

The component of the return value connects a PlayerActor to the framework router. It keeps the actor state and the browser URL in step, in both directions.

The component creates the bridge synchronously, during its own evaluation, because this is the execution model of Solid. It disconnects the bridge in onCleanup, when Solid disposes of the component. React is different: the stability of a prop is no concern here, because the props accessor of Solid is reactive already, and the component creates the bridge one time for each of its instances.

Type Parameters

Type Parameter
TRouter

Parameters

ParameterTypeDescription
BridgeCtorPlayRouterBridgeConstructor<TRouter>The bridge class. The provider builds it as new BridgeCtor(router, actor, routeMap).

Returns

A PlayRouterProvider component. It is generic over the actor type. Therefore the renderer callback receives the same concrete actor type as the prop.

<TActor>(props) => any

Example

export const PlayRouterProvider = createPlayRouterProvider(MySolidRouterBridge);