Sunday, May 19, 2024
127
rated 0 times [  130] [ 3]  / answers: 1 / hits: 9162  / 8 Years ago, mon, july 18, 2016, 12:00:00

So I am following a course on React Native that seems to be a little out of date.
Just trying to import a single component.



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;


I have looked around and I am not doing wrong what others where


More From » react-native

 Answers
44

Text should be imported from react-native. In TaskList try to do



 import { 
Text,
} from 'react-native'


instead of



 const {
Text,
} = React;

[#27297] Sunday, July 17, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kalli

Total Points: 589
Total Questions: 105
Total Answers: 97

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
;