redux-auth-wrapper icon indicating copy to clipboard operation
redux-auth-wrapper copied to clipboard

Optional redirectPath?

Open alvelig opened this issue 6 years ago • 1 comments

connectedReduxRedirect({
  //redirectPath: "/login", <--- should not be required as it's overridden by redirectAction
  redirectAction: (currentLocation) => ({
    type: "AUTHENTICATION_REQUIRED",
    payload: currentLocation
  }),
  authenticatedSelector,
})

Should redirectPath option in connectedReduxRedirect be optional when redirectAction is used?

That would be handy in ReactNative using ReactNavigation with Redux integration, or other no-location redux-based navigators, or implementing redux-saga navigation control for example.

Or if we use router, but rely on redux, then if redirectPath is undefined, pass current router location, thus allowing to dispatch action with payload containing current location.

alvelig avatar Sep 09 '17 21:09 alvelig

Hmm this is interesting. Right now the redirectPath is necessary for the connected versions because its used to build the new location. Its not the "currentLocation" but rather the location to redirect to. I could see a use for no-location based navigators, but I think that should be its own helper HOC, built on top of the same helpers as opposed to tweaking one that might make it more confusing for the majority of users. What parameters would you want in such an HOC? I could also see just passing the old location to the redirectAction in case you want to dispatch an action based on it. That seems like an easy improvement that doesn't break anything.

mjrussell avatar Oct 22 '17 17:10 mjrussell