- 深入理解React Router:从原理到实践
- 李杨韬
- 100字
- 2025-02-26 04:47:09
2.4.3 history监听
与browserHistory、hashHistory一样,memoryHistory也可对location变化进行监听:

调用history.push、history.replace、history.go分别对应的action为PUSH、REPLACE和POP。
由于内存路由没有外部的浏览器环境,不需要对任何的外部事件进行监听,所以listen源码实现可将回调函数存储到内存数组中即可:
