为什么这个组件不起作用?

问题描述 投票:0回答:2

我已经开始学习react-native而我正在尝试创建一个组件但是,当我看到代码时出现错误。有人知道为什么这个组件不起作用?

Image of code

android react-native mobile
2个回答
0
投票

您需要像这样从'react'包中导入Component

import React, { Component } from 'react'

或者,您可以使用已导入的React类中的Component,就像这样

   class MeuComponente extends React.Component {
     // your code here
   }

两种解决方案都是等价


0
投票

你需要使用已导入的React类中的Component,如下所示:Component for React.Component

© www.soinside.com 2019 - 2024. All rights reserved.