0

I am working on ReactJS and Redux. I have a file named actionTypes.js. In this file, I have the following export statement:

export const REGISTER_USER = 'REGISTER_USER';

Now, I import it in registerReducer.js with the statement:

import {REGISTER_USER} from '../actions/actionTypes';

However, when I use this REGISTER_USER variable in my registerReducer.js file, it gives the following error:

Attempted import error: 'REGISTER_USER' is not exported from '../actions/actionTypes'.

When I only import REGISTER_USER but not use it, then the warning declared but not used is issued. I am unable to understand the problem.

Note: All the paths and variable names are correct. I have verified it many times.

1
  • May be you have issues with bundling? Are you using webpack? Please share details Commented Dec 20, 2019 at 6:00

2 Answers 2

1

It might have been a bundling issue with webpack. I have ran into this issue before using react v16.10.2. I haven't seen this issue in a while though. A simple restarting/rebundling might have solved this for you.

Sign up to request clarification or add additional context in comments.

Comments

0

The problem is resolved. No code changes were needed. I just created another dummy variable in actionTypes.js and then removed that variable. Everything remained same and the code executed successfully. God knows how it happened.

3 Comments

If you've just one export then you have to call named import, like import REGISTER_USER, but when you've more than one, then it's object of exports, and hence import {REGISTER_USER}. In future, if you know this, this will help you solve issues.
@Bikas I was doing the same. As I have in my answer, that the problem was solved without any changes. Now, my new question may be why it executed without any changes. :P
Maybe you forgot to save actionTypes.js file when adding the REGISTER_USER const XD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.