[SOLVED] "Uncaught ReferenceError: dispatch is not defined"


#1

I am getting this error in a component that calls an “addTodo” action.

I have imported the action to this component’s file. Do I need to import the dispatch function from redux? What does the import statement look like?

I have a few example meteor/react/redux repos open but can’t seem to find anyone doing that.


#2

oops. he passes it in as a destructured prop:

function AddTodo({ dispatch }) {
  let input;
  return (
    <div>
      <input ref={function (node)  {
        input = node;
      }}/>
      <button onClick={function () {
        console.log('YO');
        dispatch(addTodo(input.value));
        input.value = '';
      }}>
        Add Todo
      </button>
    </div>
  );
}

from this tutorial

I didn’t see that