【问题标题】:React Native unable to resolve module X from 'pathToApp.js': could not resolve 'pathToComponentName' as a file nor as a folderReact Native 无法从“pathToApp.js”解析模块 X:无法将“pathToComponentName”解析为文件或文件夹
【发布时间】:2018-04-15 11:25:53
【问题描述】:

我的导入声明:

import Stuff from './components/Stuff';

我的目录布局是以explr为父目录,components目录是父目录的直接子目录,而import语句所在的App.js在父目录中。

我的“Stuff.jsx”:

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

export default class Stuff extends React.Component {
  render () {
    return (
      <View style={styles.sidebar} />
    )
  }
}

const styles = StyleSheet.create({
  sidebar: {
    position: 'absolute',
    left: 0,
    top: 20,
    height: '100%',
    width: 200,
    backgroundColor: 'lightslategrey',
    display: 'flex',
    flexDirection: 'column'
  },
})

【问题讨论】:

    标签: react-native


    【解决方案1】:

    React Native 不支持导入 .jsx 文件。见my answer here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-11
      • 2016-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-15
      相关资源
      最近更新 更多