Skip to content

Commit

Permalink
feat: add prop to disable the initial props cache
Browse files Browse the repository at this point in the history
  • Loading branch information
crash7 committed Oct 5, 2019
1 parent 2bbb29f commit 0ddd9f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/client/src/Before.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const reducer = (state: BeforeState, { location, type }: BeforeAction) => {
* @function
*/
export function Before(props: BeforeComponentWithRouterProps) {
const { data, routes, location, req, history } = props;
const { data, routes, location, req, history, disableInitialPropsCache } = props;
const [state, dispatch] = useReducer(reducer, {
currentLocation: location
});
Expand Down Expand Up @@ -192,7 +192,7 @@ export function Before(props: BeforeComponentWithRouterProps) {
useEffect(() => {
const unlisten = history.listen((location, action) => {
interrupt.current = action === 'POP';
if (!initialProps.current[location.pathname]) {
if (disableInitialPropsCache || !initialProps.current[location.pathname]) {
// This solves a weird case when, on an advanced step of the flow, the user does a browser back
const route = getRouteByPathname(location.pathname, routes);
if (route) {
Expand Down

0 comments on commit 0ddd9f6

Please sign in to comment.