Description
Description
Hot reload doesn't work with named exports like that:
components/index.js
import Comp1 from './Comp1'
import Comp2 from './Comp2'
export { Comp1, Comp2 }
Both Comp1 and Comp2 are functional components.
The following error is thrown when hot reloading is enabled and I change something in Comp1:
Requiring module "app/Navigator.js", which threw an exception: Error: Requiring module "app/components/index.js", which threw an exception: TypeError: Attempting to change the getter of an unconfigurable property.
If I change the component into a class based one it works.
Reproducible Demo
Create a new project with react-native init
, make a components directory with one functional component:
import React from 'react'
import { Button } from 'react-native'
const MyButton = props => <Button {...props} />
export default MyButton
and an index.js file
import MyButton from './MyButton'
export { MyButton }
and use it in App.js
import { MyButton } from './components'
...
<MyButton title="PressMe" onPress={this.handlePress} />
Now, enable hot reloading, go to MyButton and change something (optional) and save it. You should get a similar error.
Environment
React Native Environment Info:
System:
OS: macOS 10.14
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 735.79 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.11.3/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.3, 25.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.2, 28.0.3
System Images: android-23 | Intel x86 Atom, android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5014246
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.1 => 16.6.1
react-native: 0.57.7 => 0.57.7
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7