4.0.3 • Published 6 years ago

react-steersman v4.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

React Steersman

Tiny fast and real cross-platform react navigation library

NPM version Downloads Build Status

Documentation

Usage

Simple browser example with decorators

import React from 'react';
import { render } from 'react-dom';
import Steersman from 'react-steersman/Steersman';
import createBrowserHistory from 'react-steersman/createBrowserHistory';
import withRoute from 'react-steersman/withRoute';

const history = createBrowserHistory();

@withRoute({ path: '/' })
class Dashboard extends Component {
  render() {
    const { someProp } = this.props;
    return someProp;
  }
}

render(
  <Steersman history={history}>
    <Dashboard someProp="someProp"/>
  </Steersman>,
  document.getElementById('app'),
);

Simple browser example

import React from 'react';
import { render } from 'react-dom';
import Steersman from 'react-steersman/Steersman';
import createBrowserHistory from 'react-steersman/createBrowserHistory';
import Route from 'react-steersman/Route';

const history = createBrowserHistory();

function Dashboard({ direction, status }) {
  return `Dashboard ${direction}-${status}`;
}

function User({ match: { username } }) {
  return `User ${username}`;
}

render(
  <Steersman history={history}>
    <Route path="/" children={Dashboard}/>
    <Route path="/user/:username" children={User}/>
  </Steersman>,
  document.getElementById('app'),
);

Simple react-native example

import React, { Component } from 'react';
import Steersman from 'react-steersman/Steersman';
import createMemoryHistory from 'react-steersman/createMemoryHistory';
import Route from 'react-steersman/Route';

const history = createMemoryHistory();

function Dashboard({ direction, status }) {
  return `Dashboard ${direction}-${status}`;
}

function User({ match: { username } }) {
  return `User ${username}`;
}

export default class App extends Component {
  render() {
    return (
      <Steersman history={history}>
        <Route path="/" children={Dashboard}/>
        <Route path="/user/:username" children={User}/>
      </Steersman>
    );
  }
}

registerRootComponent(App);

Browser example with transitions

import React, { Component } from 'react';
import { render } from 'react-dom';
import Steersman from 'react-steersman/Steersman';
import createBrowserHistory from 'react-steersman/createBrowserHistory';
import Route from 'react-steersman/Route';

const history = createBrowserHistory();


function Dashboard({ className }) {
  return (
    <div className={className}>
      {`Dashboard ${direction}-${status}`}
    </div>
  );
}

class User extends Component {
  render() {
    const { className, match: { username } } = this.props;
    return (
      <div className={className}>
        {`User ${username}`}
      </div>
    );
  }
}

function mapProps({ direction, status }) {
  return {
    className: `fade-${direction}-${status}`,
  };
}

render(
  <Steersman history={history} mapProps={mapProps}>
    <Route path="/" children={Dashboard}/>
    <Route path="/user/:username" children={User}/>
  </Steersman>,
  document.getElementById('app'),
);

Render one route from a group routes

import React from 'react';
import { render } from 'react-dom';
import Steersman from 'react-steersman/Steersman';
import createBrowserHistory from 'react-steersman/createBrowserHistory';
import Route from 'react-steersman/Route';

const history = createBrowserHistory();

render(
  <Steersman history={history}>
    <Route path="/" children={() => 'Home Top Bar'} group="top-bar"/>
    <Route path="/profile" children={() => 'Profile Top Bar'} group="top-bar"/>
    <Route path=".*" children={() => 'Other page Top Bar'} group="top-bar"/>
    <Route path="/" children={() => 'Home'} />
    <Route path="/profile" children={() => 'Profile'}/>
  </Steersman>,
  document.getElementById('app'),
);

License

License The MIT License Copyright (c) 2017-2018 Ivan Zakharchanka

4.0.3

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.1-0

6 years ago

4.0.0

6 years ago

4.0.0-2

6 years ago

4.0.0-1

6 years ago

4.0.0-0

6 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.10.4

6 years ago

2.10.3

6 years ago

2.10.2

6 years ago

2.10.1

6 years ago

2.10.0

6 years ago

2.9.1

6 years ago

2.9.0

6 years ago

2.8.1

6 years ago

2.8.0

6 years ago

2.7.3

6 years ago

2.7.2

6 years ago

2.7.1

6 years ago

2.7.0

6 years ago

2.6.0

6 years ago

2.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.28

6 years ago

0.1.27

6 years ago

0.1.26

6 years ago

0.1.25

6 years ago

0.1.24

6 years ago

0.1.23

6 years ago

0.1.22

6 years ago

0.1.21

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago