我已經爲我想要直接導入的常用組件設置了我的React項目。流程似乎不尊重包括選項?
src/
---components/
---common/
---/TextInput
---/TabSelector
Full folder structure from root
每個common
這些文件夾中有一個index.jsx(和其他資源,如風格等)與和export default <name>
聲明。
所以我的WebPack配置具有以下配置:
resolve: {
modulesDirectories: [
'node_modules',
myCommonComponentsPath
]
}
允許直接進口:import TextInput from 'TextInput'
試圖把它添加到.flowconfig
(根據flow's documentiation)不,雖然工作:
[include]
./node_modules/
<PROJECT_ROOT>/src/components/common
這適用於webpack解析器(組件加載和工作),但流程會產生以下錯誤:
9: import TextInput from 'TextInput';
^^^^^^^^^^^ TextInput. Required module not found
任何幫助,將不勝感激。 我該如何解決這個問題?
什麼是從項目根文件夾開始的文件夾結構? – Nazim
現在通過鏈接更新。 – Horv
謝謝。你有沒有嘗試從'TextInput/index'導入TextInput; '? – Nazim