所以我正在学习React Native的课程,似乎有点过时了。 只是尝试导入单个组件。
import React, { Component } from 'react';
import { AppRegistry, Text, View } from 'react-native';
import TaskList from './TaskList';
class AwesomeProject extends Component {
constructor(props, context) {
super(props, context);
this.state = {
todos:[
{
task:'Learn React Native'
},
],
};
}
render() {
return (
<TaskList />
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
TaskList.js
import React, { Component } from 'react';
const {
Text,
} = React;
class TaskList extends Component {
render() {
return (
<Text>Hi this is the TaskList!</Text>
);
}
}
export default TaskList;
我环顾四周,其他地方我没有做错
答案 0 :(得分:8)
Text
导入 react-native
。在TaskList
尝试做
import {
Text,
} from 'react-native'
而不是
const {
Text,
} = React;