Calling one action from another action creator
I see 2 errors:
You're importing the
fetchSearchResults
function incorrectly.This is where the
TypeError _search2.default
is coming from:Uncaught TypeError: (0 , _search2.default) is not a function
You're dispatching the
fetchSearchResults
action/thunk incorrectly
Error 1: Incorrect import
// This won't work. fetchSearchResults is not the default exportimport fetchSearchResults from './search';// Use named import, instead.import {fetchSearchResults} from './search';
Error 2: Incorrect action usage
// This won't work, it's just a call to a function that returns a functionfetchSearchResults()// This will work. Dispatching the thunkdispatch(fetchSearchResults())