-
Notifications
You must be signed in to change notification settings - Fork 262
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
Cannot read property 'getIn' of undefined #20
Comments
I have the same issue |
I got the same error, which seemed to be caused by not having the reducer specified
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. |
If you use 'combineReducers' from 'redux-immutable' as opposed to 'redux', it will throw that error because, in order to get the 'auth' state, it needs to be retrieved via 'store.getState().get('auth')' as opposed to 'store.getState().auth', since it is now an immutable. How is it possible to work around this? I am using redux-immutable for combineReducers and would like to keep it this way. |
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:
|
I'm getting the same error but probably on a different place (a promise?) This happens as soon as I render |
@dpereira411, have you added AuthGlobals component to your root template? Have you executed configure from 'redux-auth'? |
I'm having this issue too, even after setting up AuthGlobals, the reducer and executing configure |
@lynndylanhurley Hey maybe time to do something, people can't use your module :) |
@L1br3 - write me a failing test and I'll fix it. |
Sorry @lynndylanhurley but I definitely stoped using your module as I couldn't make it work because of this error. I just alarm you on the importance of this blocking problem. |
I cannot reproduce this issue. That may be because it's been fixed in one of the latest releases, or because your environments are different than mine. So I'm going to close this issue out. Anyone, feel free to re-open the issue (or create a duplicate) if you can provide a failing test, or if you can explain how your environment is different from the working demo app and how that difference is causing problems. |
@lynndylanhurley If it helps at all, I was trying to implement this in a https://github.com/mxstbr/react-boilerplate/tree/master/app boilerplate app, after including |
Thanks @arjshiv, that may be the case. |
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 :) |
@lynndylanhurley Please check out this commit to see what I had: arjshiv/redux-auth-test@dab0355 You'll need to run You'll need to uncomment the line in https://github.com/arjshiv/redux-auth-test/blob/dab0355965705d78e7ff812bf6358dc5620e6e89/app/containers/HomePage/index.js to see the exact issue replicated |
For more context, this is on MacOS |
@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 In your application, the entire store is an Immutable.js 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? |
@lynndylanhurley Thanks for taking a look. The most immediate workaround I can think of is not to use |
Hey guys, any updates on this ? @lynndylanhurley |
@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. |
No worries, appreciate the help! On Tue, Jul 26, 2016 at 11:33 AM Lynn Dylan Hurley notifications@github.com
|
Hi all, +1 on the redux-immutable problem. I also tried the workaround but it doesn't work as combineReducers creates an immutable object which is passed to the connect function. export default connect(({auth}) => ({auth}))(AuthGlobals); It breaks, since the param given to connect is not a plain object. this could be solved by changing the selector to something like: (state) = > {
let auth = state.auth;
if (!auth) {
auth = state.get('auth')
}
return auth;
} Would this approach be approved if I submit a PR? |
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. |
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 :) |
@jimbofreedman, By the meantime I think you could fork the repo and do what I did on my last comment. |
@jimbofreedman I did what you told to do, and I could get it working, but after including AuthGlobals I got the same error from before (connect.js:154 Uncaught (in promise) TypeError: Cannot read property 'getIn' of undefined(…)). Where did you include the AuthGlobals in your project? (using react-boilerplate) EDIT: Ooops, my bad, I forgot to update TokenBridge.js to: |
I was bumping into this issue. My problem was that I was using |
Same problem as @alukach integrating with |
@MrHash I believe someone finishing the PR from #62 would do the trick. Also, I think you could lean on the persistStore(store, { transforms: [ createTransform(
(state) => state.toJS(),
(state) => Immutable. fromJS(state)
)
] }) Let me know what ends up working for you. |
Hey @lynndylanhurley any news with fixing this issues or removing useless immutable.js dependency? |
Hi, I have the same issue, which I could fix when server rendering by adding the following: It fixes the issue when server side rendering because now you can access the The problem on the client side comes (I think) from the fact that the state being immutable, the state object is overwritten every time the state changes, so the defined getter does not exist anymore. One solution would be to patch redux-immutable to redefine the Another solution that would come from redux-auth library would be to add named export to every component module and let the developper declare how to connect to the store himself, that is by doing as previously proposed: Any thought on the above solutions? Thanks in advance, |
Just to update on my previous comment:
It is not very nice but it solves the problem and I don't see any side effect so far. |
I know this was a year ago, but could you expand on this @OriaLogic ? Could you provide the context of where you're creating your store and reducer? I can't seem to get it working. |
I'm getting error when rendering
I'm specifying both required
provider
andendpoint
props, but I get this error:Uncaught TypeError: Cannot read property 'getIn' of undefined
The text was updated successfully, but these errors were encountered: