0.2.6 • Published 6 years ago

react-router-enter v0.2.6

Weekly downloads
6
License
ISC
Repository
github
Last release
6 years ago

react-router-enter

an onEnter hoc for react-router 4

Usage

npm i react-router-enter

// commonjs
import onEnter from 'react-router-enter'
// es
import onEnter from 'react-router-enter/es/onEnter'

function beforeEnter(props) {
  //you can achieve props passed by parent
  //should return promise
  return new Promise((resolve, reject) => {
    //enter App 10s later
    setTimeout(resolve, 10000)
  })
}

class App extends Component {
  render() {
    return (
      <div className="app">
        <Switch>
          <Route exact path="/" component={HomePage} />
          <Route path="/demo" component={DemoPage} />
        </Switch>
      </div>
    )
  }
}

export default onEnter(beforeEnter)(App)

api

onEnter(beforeEnter: func, WaitingComponent: Component?)

  • beforeEnter: you can do things before enter, should return promise;

  • WaitingComponent: you can also provide a waiting Component(default: null), this Component will show when doing beforeEnter things

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago