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

9.15.0 • Public • Published

Hello World

import { StateNavigator } from 'navigation';
import { NavigationHandler, NavigationContext } from 'navigation-react';
import { NavigationStack,. Scene } from 'navigation-react-native';

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

const Hello = () => {
  const { stateNavigator } = useContext(NavigationContext);
  return (
    <Button
      title="Hello"
      onPress={() => {
        stateNavigator.navigate('world', { size: 20 });
      }} />
  );
};

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

const App = () => (
  <NavigationHandler stateNavigator={stateNavigator}>
    <NavigationStack>
      <Scene stateKey="hello"><Hello /></Scene>
      <Scene stateKey="world"><World /></Scene>
    </NavigationStack>
  </NavigationHandler>
);

Package Sidebar

Install

npm i navigation-react-native

Weekly Downloads

135

Version

9.15.0

License

Apache-2.0

Unpacked Size

1.11 MB

Total Files

295

Last publish

Collaborators

  • grahammendick