@@ -1,4 +1,4 @@
1−import React, { useContext, useState, useEffect } from 'react';
1+import React, { forwardRef, useContext, useState, useEffect } from 'react';
22import { last, includes } from 'lodash';
33
44import { BRIDGE_ERROR } from '../lib/error';
@@ -29,10 +29,9 @@ export function HistoryProvider({ initialRoutes = [], children }) {
2929 };
3030
3131 // Scroll to top of page with each route transition.
32− useEffect(() => {
33− window.scrollTo(0, 0);
34− }, [history]);
32+ useEffect(() => window.scrollTo(0, 0), [history]);
3533
34+ // set up handlers
3635 useEffect(() => {
3736 window.history.pushState(null, null, null);
3837
@@ -40,6 +39,8 @@ export function HistoryProvider({ initialRoutes = [], children }) {
4039 window.history.pushState(null, null, null);
4140 value.pop();
4241 };
42+
43+ // TODO: disposer functon
4344 });
4445
4546 return (
@@ -48,11 +49,12 @@ export function HistoryProvider({ initialRoutes = [], children }) {
4849}
4950
5051// HOC version
51−export const withHistory = Component => props => (
52− <HistoryContext.Consumer>
53− {history => <Component history={history} {...props} />}
54− </HistoryContext.Consumer>
55−);
52+export const withHistory = Component =>
53+ forwardRef((props, ref) => (
54+ <HistoryContext.Consumer>
55+ {history => <Component ref={ref} history={history} {...props} />}
56+ </HistoryContext.Consumer>
57+ ));
5658
5759// Hook version
5860export function useHistory() {