Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Latest commit

 

History

History
68 lines (49 loc) · 1.51 KB

basics.en.md

File metadata and controls

68 lines (49 loc) · 1.51 KB

🇬🇧 (EN | RU)

Navigator object

This is a main part of the library, most of the functionality is provided by it. To get navigator object you need to either call useNavigator:

import { useNavigator } from "vkui-navigation";

const Component = () => {
  const navigator = useNavigator();
};

or use withNavigator HOC to pass navigator in props:

import { withNavigator } from "vkui-navigation";

const Component = ({ navigator }) => {
  
};

const FinalComponent = withNavigator(Component);

Replacing VKUI

To handle navigation, you need to replace View/Root from VKUI with the ones from vkui-navigation. Note that some properties are different.

View

import { View } from "vkui-navigation";

return (
  <View homePanel="panel1">
    <Panel1 />
    <Panel2 />
  </View>
);

Properties

Name Description
homePanel Required. Default Panel ID

All the properties from original View are accepted except activePanel, history, popout and onSwipeBack.

Root

import { Root } from "vkui-navigation";

return (
  <Root homeView="view1">
    <View1 />
    <View2 />
  </Root>
);

Properties

Name Description
homeView Required. Default View ID

All the properties from original Root are accepted except activeView.

Navigation →