我遇到了一个奇怪的问题。直接从Input
导入../Input
组件是在defined
之外的TestComponent
,但是,从'../index'文件导入Input的是not defined
在{{1}之外}
TestComponent
输入-> index.js
import Input from '../Input';
import { Input as Input2 } from '../index';
console.log(Input, Input2) //Input2 is undefined, whereas Input is defined
const { Search } = Input;
const { Search: Search2 } = Input2 // gives reading property Search of Undefined
const TestComponent = (props) => {
return (
<Search/>
<Input2.Search/> // is working
)
}
index.js
import Search from './Search';
const Input = (props) => {
return (<input value={props.value} />)
}
Input.Search = Search;
export default Input;
请有人帮助我了解此问题。