The translation was generated automatically and may contain mistakes
createHashRouter
Use this function to create Hash router in your React app.
Hash 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 # , например:
https://vk.com/app12345/#/persik-screen
As a parameter, the function takes an array, the elements of which describe the routes - which screen or window will be opened when you go through a particular URL in the APPLICATION.
Example
import { RouterProvider, createHashRouter } from '@vkontakte/vk-mini-apps-router';
// ?1?’ызов функции
const router = createHashRouter([
{
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.
Other examples
Examples of the use of the function can also be found in the sections Installation and Connection ?1? Setting up routes .
Announcement
export function createHashRouter(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 # In the URL, in the not necessary .
Materials on the topic
- •
- •
- •
- •
- •
- •
- •
- •