navigation-react
TypeScript icon, indicating that this package has built-in type declarations

4.5.1 • Public • Published

Hello World

import { StateNavigator } from 'navigation';
import { NavigationHandler, NavigationLink, NavigationContext, SceneView } from 'navigation-react';

const stateNavigator = new StateNavigator([
  { key: 'hello', route: '' },
  { key: 'world' }
]);

stateNavigator.start();

const Hello = () => (
  <NavigationLink
    stateKey="world"
    navigationData={{ size: 20 }}>
    Hello
  </NavigationLink>
);

const World = () => {
  const { data } = useContext(NavigationContext);
  return (
    <div style={{ fontSize: data.size }}>World</div>
  );
};

const App = () => (
  <NavigationHandler stateNavigator={stateNavigator}>
    <SceneView active="hello"><Hello /></SceneView>
    <SceneView active="world"><World /></SceneView>
  </NavigationHandler>  
);

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i navigation-react

      Weekly Downloads

      80

      Version

      4.5.1

      License

      Apache-2.0

      Unpacked Size

      20.2 kB

      Total Files

      4

      Last publish

      Collaborators

      • grahammendick