react-native
react-native copied to clipboard
doc about path alias config is error
Description
babel.config.js
module.exports = function (api) {
api.cache(true)
return {
presets: ['babel-preset-expo', 'module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolve',
{
root: ['.'],
extensions: ['.ios.js', '.android.js', '.js', '.ts', '.tsx', '.json'],
alias: {
'@components': './components',
'@assets': './assets',
},
},
],
'react-native-reanimated/plugin',
],
}
}
// tsconfig.json
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"baseUrl": ".",
"paths": {
"@components/*": ["components/*"],
"@assets/*": ["assets/*"]
}
}
}
// usage
import { SafeAreaLayout } from '@components/SafeAreaLayout'
Unable to resolve module @components/SafeAreaLayout from /Users/vayne/wmqj/expo-rn/navigation/SideMenuDrawer.tsx: @components/SafeAreaLayout could not be found within the project or in these directories:
node_modules
2 | import React, { FC } from 'react'
3 | import { Avatar, Drawer, DrawerGroup, DrawerItem, Icon, Text } from '@ui-kitten/components'
> 4 | import { SafeAreaLayout } from '@components/SafeAreaLayout'
| ^
Version
0.69
Output of npx react-native info
expo start --ios
Steps to reproduce
expo start --ios
Snack, code example, screenshot, or link to a repository
https://reactnative.cn/docs/typescript
Same issue
Same issue
youself submit aissue
same here
replace @ to else Character,, like #
@codiri
Closing as we don't maintain reactnative.cn You'll have to report this to the Chinese Website maintainers