React: Uncaught TypeError: (0 , _action2.default) is not a function if action imported without curly braces

Created on 17 May 2016  路  5Comments  路  Source: facebook/react

Using React 0.14.8 I see following behavior:
When I want to import actions for Redux, I should import like that:
import {setSomeVar} from './actions.js'
if I try to import like I'm used to import single React components, without curly braces:
import setSomeVar from './actions.js'
after bundling I see following exception on doing
this.props.dispatch(setSomeVar(someVar))
I see this exception:
Uncaught TypeError: (0 , _action2.default) is not a function

Most helpful comment

All 5 comments

Hi! We use React issue tracker for bugs in React.
What you describe sounds more like a usage question about Redux.

We ask that you ask usage questions on StackOverflow instead.
Please feel free to leave a link here in the comment!

Cheers.

I had the same Issue. From the actions.js function should have export. example
export function blah(){..} then it does not show the error.

Found this from Google.

In my case it was because I was importing A.js from B.js, and B.js from A.js.

i am also face this error in
export default function getUser() {...}
then i removed default from function and now its work, like
export function getUser() {...}

Was this page helpful?
0 / 5 - 0 ratings