How to view react source code

王林
Release: 2020-11-30 10:43:46
Original
4304 people have browsed it

How to view the react source code: 1. Enter the react official website; 2. Download the packages file locally; 3. Open the index.js file, which is the entry file of the react source code. We can also convert react source code through babel.

How to view react source code

The operating environment of this tutorial: windows10 system, react16 version. This method is suitable for all brands of computers.

(Learning video sharing:react video tutorial)

The specific method is as follows:

1. Enter the official website

https://github.com/facebook/react
Copy after login

2. The source codes are all in the packages file

https://github.com/facebook/react/tree/master/packages
Copy after login

3. You can download the file locally, which will look more convenient

4. Then enter the pageages/react/index.js file, this file It is the entrance to the react source code

5. This URL can display the react code as the code converted by babel

https://react.docschina.org/
Copy after login

Example:

import React, { Component } from "react"; import ReactDOM from "react-dom"; import "./index.css"; function FuncCmp(props) { return 
name: {props.name}
; } class ClassCmp extends Component { render() { return
name: {this.props.name}
; } } const jsx = (

我是内容

); ReactDOM.render(jsx, document.getElementById("root"));
Copy after login

After compiled by babel:

function FuncCmp(props) { return React.createElement( "div", null, "name: ", props.name ); } class ClassCmp extends React.Component { render() { return React.createElement( "div", null, "name: ", this.props.name ); } } let jsx = React.createElement( "div", null, " ", React.createElement( "div", { className: "border" }, "我是内容" ), " ", React.createElement(FuncCmp, { name: "我是function组件" }), " ", React.createElement(ClassCmp, { name: "我是class组件" }), " " ); ReactDOM.render(jsx, document.getElementById('root'));
Copy after login

Related recommendations:js tutorial

The above is the detailed content of How to view react source code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!