I have a folder structure like this:
src\
components\
Home\
index.tsx
redux\
reducer.ts
index.tsx
In ./index.tsx
in have
export const App = <p> Hello World </p>
When i try to import { App } from ../index.tsx
in reducer.js
is say App is undefined
But if i import Home from '../components/Home'
it works well.
What could be the issue?
import { App } from ../index
? You should import js
rather than jsx
. Which is, I suppose, compiled and stored next to your .jsx
files. You can also update your webpack config in order to import jsx directly, not sure it's an option in this case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.