Skip to content

Variable: PlayRouterProvider

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

const PlayRouterProvider: <TActor>(props) => any;

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

Connects a PlayerActor to Solid 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.

Take the router prop from the Solid Router hooks in the parent component:

function AppShell() {
const navigate = useNavigate();
const location = useLocation();
const params = useParams();
return (
<PlayRouterProvider
actor={actor}
routeMap={routeMap}
router={{ navigate, location, params }}
renderer={(a) => <PlayRenderer actor={a} registry={registry} />}
/>
);
}

Type Parameters

Type Parameter
TActor extends PlayActor

Parameters

ParameterType
propsPlayRouterProviderBaseProps<SolidRouterHooks, TActor>

Returns

any