Thanks to the Ken Rogers book I’m moving along very well in getting up to speed on Meteor/Mantra/React. I’ve gotten routing, containers and components working and now I’m setting up my first actions.
It seems like I’ve done everything I’m supposed to do with regard to actions, but I’m still getting this console error:
export const depsMapper = (context, actions) => ({
create: actions.myCanines.create, <==ERROR: CANNOT READ PROPERTY ‘CREATE’ OF UNDEFINED
clearErrors: actions.myCanines.clearErrors,
context: () => context
});
It’s bound to be some super-newbie thing but I’ve been over sample code from Ken and others and haven’t yet spotted what I’m leaving out. What am I missing?
FOLDER LAYOUT
modules directory
–myCanines directory
----actions directory
--------index.js
--------myCanines.js
----container directory
--------newmyCanine.js
--------myCaninesList.js
----components directory
--------myCaninesList.jsx
--------newmyCanine.jsx
----index.js
FILE CONTENTS
modules directory
–myCanines directory
----index.js:
import actions from ‘./actions’;
import routes from ‘…/core/routes.jsx’;
export default {
routes,
actions
};
----actions directory
------index.js
import myCanines from './myCanines'; export default { myCanines };
----actions directory
------myCanines.js
export default { create({Meteor, LocalState, FlowRouter}, name) { if (!name) { return LocalState.set('CREATE_Canine_ERROR', 'Job Specialty name is required.'); } LocalState.set('CREATE_Canine_ERROR', null); Meteor.call('myCanines.create', name, (err) => { if (err) { return LocalState.set('SAVING_ERROR', err.message); } }); FlowRouter.go('/myCanines'); }, clearErrors({LocalState}) { return LocalState.set('SAVING_ERROR', null); } };
----container director
------newmyCanine.js
import NewCanine from '../components/newmyCanine.jsx'; import {useDeps, composeWithTracker, composeAll} from 'mantra-core'; export const composer = ({context, clearErrors}, onData) => { const {LocalState} = context(); const error = LocalState.get('CREATE_CATEGORY_ERROR'); onData(null, {error}); // clearErrors when unmounting the component return clearErrors; }; export const depsMapper = (context, actions) => ({ create: actions.myCanines.create, clearErrors: actions.myCanines.clearErrors, context: () => context }); export default composeAll( composeWithTracker(composer), useDeps(depsMapper) )(NewCanine);
Note-- my app isn’t about dogs; I’ve just replaced my file/variable names with ‘canines’ for purposes of this post.
Thanks very much in advance to all for any info!