4

For context, let me try to explain a little more.

In my project I have a folder, as example, for components. Inside that folder I have my components files, and an index.js file where I import all the components and export than in the same line as follows:

export { default as Button } from './button'
export { default as Loader } from './loader'
export { default as ImageBackground } from './image-background'

So than I can import these components in Screen Component like that:

import { Button, Loader, ImageBackground } from 'src/components'

If I edit the components file, save and reload the project, everything works fine.

The problem is that when I edit any of these components with the Hot Module Replacement (Hot Reloading) actived, when it is triggered after an edit, it throws the following error:

Unhandled JS Exception: Requiring module "src/components/index.js", which threw an exception: TypeError: Cannot redefine property: Button

Has anyone have any idea why this is happening?

Thanks in advance!

Obs: When I import the component direct without using the index.js or if inside the index.js, I first import the component, than I assign the component to a variable and than I export this variable, it works fine.

Kaleb Portilho
  • 1,181
  • 16
  • 20

1 Answers1

0

my problem was solved when I changed render = () => (...) to render(){ return (...)} in react component

Swain
  • 21
  • 3