react-native - react-native 中渲染的用途和功能是什么?

标签 react-native

render() 的实际用途是什么。为什么要使用它?我们可以在基于函数和类的组件中使用它吗?

import React, { Component } from 'react';
import { AppRegistry, Text } from 'react-native';

export default class HelloWorldApp extends Component {
  render() {
    return (
     <Text>Hello world!</Text>
    );
  } 
}


AppRegistry.registerComponent('AwesomeProject', () => HelloWorldApp);

最佳答案

功能组件本质上其类伴侣的render功能。

const render = props => <div />

同:

class extends Component {
  render() { return <div /> } // props via this.props
}

它是 React 中最重要的功能,因为它告诉你的目标(Web 或 native )在屏幕上显示什么。

关于react-native - react-native 中渲染的用途和功能是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45040163/

相关文章:

android - 如何在 React Native (android) 中同步 gradle?

javascript - 当没有在 React 构造函数中访问 props 时,将 props 传递给 super() 的原因是什么?

react-native - React Native Android App 体积很大

javascript - 在 React-Native 中设置可重用组件的样式

ios - 应用商店更新 React Native 后本地存储是否清除?

reactjs - 如何从 React Native 中的 componentDidMount 内部的函数访问 this.state ?

reactjs - react native : Uncaught (in promise) Error: DeltaPatcher should receive a base Bundle when being initialized

ios - 必须将 AirGoogleMaps 目录添加到您的 xCode 项目以支持 iOS React Native 上的 GoogleMaps

ios - 如何在 Objective-C 或 Swift 上发送带有 .p12 证书的 https 请求

javascript - 如何映射列表并在其中实现异步?