-
Notifications
You must be signed in to change notification settings - Fork 50.5k
Closed
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
React component imported from index.js file, which exports all components in one place returns undefined outside render function in container component. Path to components folder is resolved by webpack config resolve.modules option.
My file structure is:
├── components
│ ├── index.js
│ └── ui
│ ├── Checkbox.jsx
index.js file content:
/**
* UI components
*/
export Checkbox from './ui/Checkbox';Container file component:
import React, { Component } from 'react';
import { Checkbox } from 'components'; // => undefined
import Checkbox from 'components/ui/Checkbox'; // => component function
/**
* Returns `undefined` when imported from index.js file in components folder
* Returns component function when imported directly from `components/ui` folder
*/
console.log(Checkbox);
/**
* Update: Returns component function in both cases
*/
setTimeout(() => {
console.log(Checkbox);
}, 100);
export default class Container {
render() {
/**
* Returns component function in both cases
*/
console.log(Checkbox);
return <div>test</div>;
}
}What is the expected behavior?
Described in the code above.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React - 15.6.1
OS - macOS 10.12.6
Browser - Google Chrome 61.0.3163.79
Metadata
Metadata
Assignees
Labels
No labels