@aomi/mobx-history

Mobx react-router-dom

Usage no npm install needed!

<script type="module">
  import aomiMobxHistory from 'https://cdn.skypack.dev/@aomi/mobx-history';
</script>

README

Mobx history

Mobx react-router-dom

快速开始

安装

yarn install history @aomi/mobx-history

React Router 使用

import { createHashHistory } from 'history';

const history = syncHistory(createHashHistory());

const App = (
  <Router history={history}>
  </Router>
)

Api


import { navigationServices } from '@aomi/mobx-history';

export interface Location<S = LocationState> {
  pathname: Pathname;
  search: Search;
  state: S;
  hash: Hash;
  key?: LocationKey;
}

const location:Location = {}
// 进入指定页面
navigationServices.push(location)

// 替换当前页面
navigationServices.replace('/login');