Bur*_*000 2 javascript react-native
所以我正在学习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);
Run Code Online (Sandbox Code Playgroud)
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;
Run Code Online (Sandbox Code Playgroud)
我环顾四周,其他人在哪里做错了
Text应该从中导入react-native.在TaskList尝试做
import {
Text,
} from 'react-native'
Run Code Online (Sandbox Code Playgroud)
代替
const {
Text,
} = React;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8977 次 |
| 最近记录: |