The translation was generated automatically and may contain mistakes
createHashParamRouter
Use this function to create HashParam-роутер in your React app.
HashParam router is designed for games and mini-applications that run on the VKontakte platform: in the mobile application VKontakte or from the desktop or mobile version of the site.
When using this router, external links to application screens must contain a symbol # and the keyword path , например:
https://vk.com/app12345/#path=%2Fpersik-screen¶m1=value1¶m2=value2
Use this router if your application passes parameters after the # symbol to the URL.
As a parameter, the function createHashParamRouter(...) takes an array whose elements describe routes — which screen or window will be opened when you go through a particular URL in the APPLICATION.
Example
import { RouterProvider, createHashParamRouter } from '@vkontakte/vk-mini-apps-router';
// ?1?’ызов функции
const router = createHashParamRouter([
{
path: '/',
panel: 'home_panel',
view: 'default_view',
},
{
path: '/contacts',
panel: 'contacts_panel',
view: 'contacts_view',
}
]);
// Передача созданного роутера в компонент
<RouterProvider router={router}>
<App />
</RouterProvider>Please note that in the field path Symbol # not indicated.
Announcement
export function createHashParamRouter(routes: RouteWithRoot[] | RouteWithoutRoot[]): RemixRouterParameters
Parameter | Type | Description |
|---|---|---|
routes
Mandatory | An array of objects describing routes.
If there are multiple components in the application Root It is used [ Epic )( https://vkui.io/components/epic the array must be composed of objects RouteWithRoot .
Otherwise, array elements are objects RouteWithoutRoot . |
Result
Object RemixRouter . Defined in the library @remix-run/react-router .
Features of use
When creating routes>> Do not use the symbol # and the keyword path In the URL, in the not necessary .
Materials on the topic
- •
- •
- •
- •
- •
- •
- •
- •