redux-auth: Cannot read property 'getIn' of undefined

I’m getting error when rendering

<OAuthSignInButton
          provider=...
          endpoint=... />

I’m specifying both required provider and endpoint props, but I get this error:

Uncaught TypeError: Cannot read property 'getIn' of undefined

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 1
  • Comments: 34 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I got the same error, which seemed to be caused by not having the reducer specified

import {authStateReducer} from "redux-auth";
// create your main reducer
const reducer = combineReducers({
  auth: authStateReducer,
  // ... add your own reducers here
});

It’d be nice if it handled this a bit better, either handling the null value, or returning an error telling people what to do. Also, the instructions in the README don’t mention setting up the reducer. The example app certainly has it in there, but it also has a lot of other stuff that a real app doesn’t need.

Hi @lynndylanhurley ,

I just hardcoded every container of redux-auth so it access the auth state like this:

export default connect((state) => ({ auth: state.get('auth') }))

And is working, I believe that if we isolate the selector in a module so it handles the immutable case (like in my previous post) for the meanwhile, then we could further give the users the ability to customize this selector. If you guide me a bit I could help you with a PR.

@arjshiv - thanks for sending that detailed example.

@nyjy85 was right - the problem is that the redux-auth components expect there to be a normal javascript object called auth at the root level of your store. Her comment above explains the problem you’re having.

In your application, the entire store is an Immutable.js Map, and the redux-auth components don’t know how to read that.

I’ll try to include a fix this for the next release, but it will be a bit of work and I’m not sure when it will be ready by.

It looks like you’ve included @hhhonzik’s workaround:

const auth = (state = {}, action) => { //otherwise this reducer doesn't work with redux-immutable
  return authStateReducer(Immutable.fromJS(state), action);
};

But it doesn’t seem to be solving the problem.

@hhhonzik - was there anything else you needed to do to work past this issue?

Is anyone still thinking about this? I’ve hit the same issue and would rather pick up where you left off than start from scratch 😃

No worries, appreciate the help!

On Tue, Jul 26, 2016 at 11:33 AM Lynn Dylan Hurley notifications@github.com wrote:

@arjshiv https://github.com/arjshiv - I’ll need to provide a configuration option for accessing the auth reducer store from the root store. I’m super busy with work but hopefully I’ll have this ready by next Monday or so.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lynndylanhurley/redux-auth/issues/20#issuecomment-235306626, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6FO_iD0Be0Y-auAJQ5rwqZGiUuaycXks5qZijkgaJpZM4HQbq- .

No worries, I’ll have a test repo up and hopefully you can help me debug. BTW, I love what you’ve done, and I have my fingers crossed that I’ll be able to use it once we get past this 😃

Hey @nyjy85,

I came across the same issue and there is a problem with initialState being undefined or plain object.

You can just wrap authStateReducer with initial immutable state like this:

import { authStateReducer } from "redux-auth";
import Immutable from "immutable";

const auth = (state = {}, action) => {
  return authStateReducer(Immutable.fromJS(state), action);
}

const appReducer = combineReducers({
  auth,
  ...
});