react-native icon indicating copy to clipboard operation
react-native copied to clipboard

doc about path alias config is error

Open Valar103769 opened this issue 3 years ago • 2 comments

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

Valar103769 avatar Aug 26 '22 09:08 Valar103769

Same issue

BrunoFDeveloper avatar Aug 26 '22 15:08 BrunoFDeveloper

Same issue

youself submit aissue

Valar103769 avatar Aug 27 '22 05:08 Valar103769

same here

codiri avatar Dec 08 '22 22:12 codiri

replace @ to else Character,, like #

Valar103769 avatar Dec 09 '22 03:12 Valar103769

@codiri

Valar103769 avatar Dec 09 '22 03:12 Valar103769

Closing as we don't maintain reactnative.cn You'll have to report this to the Chinese Website maintainers

cortinico avatar Dec 09 '22 10:12 cortinico