Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing Props Warning React 15.3.0 #69

Closed
B-Stewart opened this issue Aug 11, 2016 · 4 comments
Closed

Passing Props Warning React 15.3.0 #69

B-Stewart opened this issue Aug 11, 2016 · 4 comments
Labels

Comments

@B-Stewart
Copy link

B-Stewart commented Aug 11, 2016

We have upgraded to React 15.3.0 from 15.1.0 and are now receiving this warning while using your wrapper.

Warning: Unknown props `history`, `location`, `params`, `route`, `routeParams`, `routes` on <span> tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop
    in span (created by RequireAuthentication(Connect(UserEvaluations)))
    in RequireAuthentication(Connect(UserEvaluations)) (created by Connect(RequireAuthentication(Connect(UserEvaluations))))
    in Connect(RequireAuthentication(Connect(UserEvaluations))) (created by RouterContext)
    in div (created by Gateway)
    in Gateway (created by Connect(Gateway))
    in Connect(Gateway) (created by RouterContext)
    in RouterContext (created by Router)
    in ScrollBehaviorContainer (created by Router)
    in Router
    in Provider

It references this documentation which deals with passing props. My guess is the way that you are passing the props to the loading component (in this case the default is making React upset.

Here are what my auth wrappers look like in case that is helpful or the issue is actually on my side

mport { UserAuthWrapper } from 'redux-auth-wrapper'

export const RequireAuthentication = UserAuthWrapper({
  authSelector: state => state.auth,
  predicate: auth => auth.isAuthenticated,
  authenticatingSelector: state => state.auth.fetching,
  wrapperDisplayName: 'RequireAuthentication'
})

export const IgnoreIfAuthenticated = UserAuthWrapper({
  authSelector: state => state.auth,
  failureRedirectPath: '/',
  predicate: auth => !auth.isAuthenticated,
  authenticatingSelector: state => state.auth.fetching,
  wrapperDisplayName: 'IgnoreIfAuthenticated',
  allowRedirectBack: false
})
@mjrussell
Copy link
Owner

Yeah you are totally correct on this, it is actually fixed by #63 and in master. I was initially waiting on a few more things for a release version but Im just going to get it out today. I'll close this when I do.

@mjrussell
Copy link
Owner

mjrussell commented Aug 11, 2016

Released 0.7.0 just now. Should be fixed.

Feel free to re-open if it isn't resolved but there is a test for it so Im fairly confident.

@larsw
Copy link

larsw commented Sep 21, 2016

Hi,

I'm experiencing the same problem (currently on version 0.8.0) when I wrap an NavDropdown control from react-bootstrap (which renders an anchor element):

Warning: Unknown props `authData, `failureRedirectPath` on <a> tag.  ...

Would it be possible to add a parameter that could disable passing props / authData, or the possibility to pass in a prop filtering function?

If disabled/filtered, an alternate version of the DecoratedComponent can be instantiated here:
https://github.com/mjrussell/redux-auth-wrapper/blob/master/src/index.js#L129

@mjrussell
Copy link
Owner

mjrussell commented Sep 21, 2016

@larsw I do want to add a parameter to disable passing the authData down, see #28. We shouldn't be passing down the failureRedirectPath though since thats probably useless to the decorated component...that seems like a bug. I would think the only thing that should be passed from the wrapper-specific props is authData and then control that with a flag.

#28 isn't hard to implement, I've just been pretty busy lately. I can try to get to it soon, but probably not for another week. In the meantime, you should be able to use a function component to wrap the control and drop the props. Something like:

const myWrapper = UserAuthWraper({
...
})

// Instead of myWrapper(NavDropdown)
myWrapper(() => <NavDropdown />)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants