Closed sloanwolf closed 8 years ago
export default alt.createActions(TodoActions, 'TodoActions');
Have you try this??
@bsdo64 No that fails with Cannot create property ____ on string 'UserActions'
What's the error? Is there an error?
Also, you're binding a new function in componentWillMount
which will cause memory leaks. https://medium.com/@goatslacker/react-0-13-x-and-autobinding-b4906189425d#.buqhe5grv
@goatslacker There is no error. Here is some debug output.
Actions
saveUser(data) {
console.log('saveUser', 'outside');
return (dispatch) => {
console.log('saveUser', 'inside dispatcher');
this.saveUserSuccess(data);
}
}
Store
onSaveUserSuccess(payload) {
console.log('saveUser', 'onSaveUserSuccess');
this.user = payload;
db._asyncSave(constants.USER_STORAGE_KEY, this.user);
}
Console
saveUser outside UserActions.js:147
saveUser inside dispatcher UserActions.js:149
I will fix up the memory leak issue though, thanks for that info.
Sorry from the Store I use this.bindActions(this.alt.getActions('UserActions'));
if that makes any difference.
Think I figured it out. Seems to be working both un-minified and minified
Changed:
this.bindActions(this.alt.getActions('UserActions'));
To
this.bindListeners({
onLoadUserSuccess: UserActions.LOAD_USER_SUCCESS,
onLoadUserFail: UserActions.LOAD_USER_FAIL,
onSaveUserSuccess: UserActions.SAVE_USER_SUCCESS,
onClearUserSuccess: UserActions.CLEAR_USER_SUCCESS,
});
Confirmed, works in minified offline bundle.
Ah yes your actions class name was getting minified and thus there was no "UserActions"
In the future you can avoid this by setting a "displayName" property on your class...
class Foo { static displayName = 'Foo'; }
I've been struggling with an issue for a week and have finally narrowed it down.
Everything works fine in when I'm debugging in React-Native normally but was failing with no error when I tried to build and run via offline bundle. Eventually I tried running via packager with
minify=true
and was able to reproduce the issue. I put in a ton of console debug between my Actions and Store and it never reaches my Store functions.Index
Store
Action
this.saveUserSuccess
never gets fired. So is there potentially an issue with the dispatcher when minified?That example is from React-Native 0.14 but still works in React-Native 0.28 EXCEPT when minified.
I wanted to check before rewriting my stores/actions to another structure if I don't have to.
Thanks!