July 2018
Beginner
236 pages
5h 34m
English
The last piece of the observable state puzzle is the HistoryTracker, a class dedicated to monitoring the browser's URL and history. It relies on the history NPM package (https://github.com/ReactTraining/history) to do most of the work. The history package also powers the react-router-dom library, which we will be using for our React components.
The core responsibility of HistoryTracker is to expose an observable called page that tracks the current URL (route) in the browser. It also does the reverse where it keeps the URL in sync with the current page:
import createHashHistory from 'history/createHashHistory';import { observable, action, reaction } from 'mobx';export class HistoryTracker { unsubscribe = null; history
Read now
Unlock full access