Skip to content

Commit 41aac49

Browse files
author
姚观寿
committed
更新react源码分析
1 parent 10657b1 commit 41aac49

20 files changed

+58
-44610
lines changed

common/js/react.development.v16.12.0.js

Lines changed: 0 additions & 4206 deletions
Large diffs are not rendered by default.

common/js/react.v16.12.0.js

Lines changed: 2 additions & 39162 deletions
Large diffs are not rendered by default.

es6.html

Lines changed: 8 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,11 @@
1-
<<<<<<< HEAD
2-
<!DOCTYPE html>
3-
<html>
4-
5-
<head>
6-
<meta charset="UTF-8" />
7-
<title>Hello React!</title>
8-
<script src="./common/js/ajax.js"></script>
9-
<!--官方提供的 CDN 地址:-->
10-
<!-- <script src="./common/js/react.development.v16.12.0.js"></script>
11-
<script src="./common/js/react-dom.development.v16.12.0.js"></script> -->
12-
<!-- <script src="./common/js/browser-polyfill.5.8.38.js"></script> -->
13-
<script src="./common/js/react.v16.12.0.js"></script>
14-
<script src="./common/js/browser.5.8.38.js"></script>
15-
16-
</head>
17-
<style>
18-
.lsft-box{
19-
float: left;
20-
width: 48%;
21-
height: 100vh;
22-
}
23-
.right-box{
24-
float: right;
25-
width: 48%;
26-
height: 100vh;
27-
}
28-
*{
29-
padding: 0;
30-
margin: 0;
31-
}
32-
.textarea{
33-
font-size: 18px;
34-
display: block;
35-
/* width: 100%;
36-
height: 100vh; */
37-
}
38-
</style>
39-
<body>
40-
41-
<div id="example" class="lsft-box"></div>
42-
<textarea id="textarea" class='textarea right-box' ></textarea>
43-
44-
<script src="./es6_code/es6_react_code/01/02.js" type="text/babel"></script>
45-
<script>
46-
47-
var oTextarea= document.getElementById('textarea');
48-
setTimeout(() => {
49-
oTextarea.value=code
50-
var oldCode = window.localStorage.getItem('code');
51-
// 如果同样代码 则不会在发送请求
52-
if(oldCode===code){
53-
return false
54-
}
55-
window.localStorage.setItem('code',code);
56-
//把代码发送到服务器
57-
ajax({
58-
url: "http://127.0.0.1:5000/createCode",
59-
type: 'post',
60-
data: {
61-
path: '/es5_code/es5_react_code/01/02.js',
62-
code: code,
63-
},
64-
dataType: 'json',
65-
timeout: 10000,
66-
contentType: "application/json",
67-
success: function (data) {
68-
console.log('data====',data)
69-
},
70-
//异常处理
71-
error: function (e) {
72-
console.log(e);
73-
}
74-
})
75-
}, 100);
76-
77-
78-
</script>
79-
80-
</body>
81-
82-
=======
1+
<!--
2+
* @Author: your name
3+
* @Date: 2021-05-06 12:29:53
4+
* @LastEditTime: 2021-05-07 10:00:58
5+
* @LastEditors: your name
6+
* @Description: In User Settings Edit
7+
* @FilePath: /react/es6.html
8+
-->
839
<!DOCTYPE html>
8410
<html>
8511

@@ -160,5 +86,4 @@
16086

16187
</body>
16288

163-
>>>>>>> 46e5d654750168326619cd5ec4cf48a1c0506d86
16489
</html>
Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,11 @@
1-
<<<<<<< HEAD
2-
// import React, { useState, useEffect } from 'react'
3-
4-
const Show =(props)=>{
5-
const {flag}=props;
6-
React.useEffect(() => {
7-
console.log(1)
8-
9-
return () => {
10-
console.log(2)
11-
12-
};
13-
});
14-
15-
return (
16-
<div> {flag?(<div> 显示</div> ):null} </div>
17-
)
18-
19-
}
20-
21-
const LazyPage = () => {
22-
const [name, setName] = React.useState("zhangsan");
23-
const [flag, setFlag] = React.useState(true);
24-
return (
25-
<div>
26-
<button
27-
onClick={() => {
28-
setFlag(false);
29-
}}
30-
>
31-
按钮
32-
</button>
33-
<Show flag={flag}> </Show>
34-
<p> My Name is: {name} </p>
35-
<input type="text" value={name} onChange={e => setName(e.target.value)} />
36-
</div>
37-
);
38-
};
39-
40-
ReactDOM.render(<LazyPage />, document.getElementById("example"));
41-
=======
1+
/*
2+
* @Author: your name
3+
* @Date: 2021-05-06 12:29:53
4+
* @LastEditTime: 2021-05-07 10:02:10
5+
* @LastEditors: your name
6+
* @Description: In User Settings Edit
7+
* @FilePath: /react/es6_code/es6_react_code/04/04_01.js
8+
*/
429
// import React, { useState, useEffect } from 'react'
4310

4411
const Show =(props)=>{
@@ -78,4 +45,3 @@ const LazyPage = () => {
7845
};
7946

8047
ReactDOM.render(<LazyPage />, document.getElementById("example"));
81-
>>>>>>> 46e5d654750168326619cd5ec4cf48a1c0506d86

scattered_deom/MessageChannel.html

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
1-
<<<<<<< HEAD
2-
<!DOCTYPE html>
3-
<html lang="en">
4-
5-
<head>
6-
<meta charset="UTF-8">
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
9-
<title>Document</title>
10-
</head>
11-
12-
<body>
13-
<script>
14-
//MessageChannel创建的新通道
15-
var channel = new MessageChannel();
16-
var port = channel.port2;
17-
// 接受信息
18-
channel.port1.onmessage = (data) => {
19-
console.log(data.data)
20-
};
21-
setTimeout(() => {
22-
port.postMessage('hello world')
23-
}, 3000);
24-
</script>
25-
</body>
26-
27-
=======
1+
<!--
2+
* @Author: your name
3+
* @Date: 2021-05-06 12:29:53
4+
* @LastEditTime: 2021-05-06 12:32:37
5+
* @LastEditors: your name
6+
* @Description: In User Settings Edit
7+
* @FilePath: /react/scattered_deom/MessageChannel.html
8+
-->
289
<!DOCTYPE html>
2910
<html lang="en">
3011

@@ -50,5 +31,4 @@
5031
</script>
5132
</body>
5233

53-
>>>>>>> 46e5d654750168326619cd5ec4cf48a1c0506d86
5434
</html>

scattered_deom/demo.html

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,3 @@
1-
<<<<<<< HEAD
2-
<!DOCTYPE html>
3-
<html lang="en">
4-
5-
<head>
6-
<meta charset="UTF-8">
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
9-
<title>Document</title>
10-
</head>
11-
12-
<body>
13-
<ul id="list">
14-
15-
16-
</ul>
17-
<script>
18-
// var s='a b c'
19-
// var reg=/^\s+|\s+/ig
20-
// s=s.replace(reg,function (s) {
21-
// console.log('s=','l ')
22-
// return 'l '
23-
// }) +'l'
24-
// console.log(s)
25-
26-
// function sum( ) {
27-
// let count = 0;
28-
// if(arguments.length==2){
29-
// count = arguments[0]+arguments[1]
30-
// return count;
31-
// }else{
32-
// count = arguments[0]
33-
// return function () {
34-
// count+=arguments[0]
35-
// return count;
36-
// }
37-
// }
38-
39-
// }
40-
// console.log( sum(2,3 ))
41-
// console.log( sum(2)(3))
42-
43-
// var ul = document.getElementById("list")
44-
// for(var i=1;i<=3;i++){
45-
// var li=document.createElement('li');
46-
// li.innerText=i;
47-
// ul.appendChild(li)
48-
// }
49-
// ul.onclick=function ( event ) {
50-
// console.log(event.target.nodeName)
51-
// if(event.target.nodeName==='LI'){
52-
// alert(event.target.innerText)
53-
// }
54-
// }
55-
// var str = 'abhudjchhhf';
56-
57-
// var conuntStr = (str) => {
58-
// var obj = {}
59-
// var index = 0;
60-
// while (index < str.length) {
61-
// if (str.charAt(index) in obj) {
62-
// obj[str.charAt(index)] += 1;
63-
// } else {
64-
// obj[str.charAt(index)] = 1;
65-
// }
66-
// index++;
67-
// }
68-
// return obj
69-
// }
70-
// const getMax = (obj) => {
71-
// var tmp = 0;
72-
// for (key in obj) {
73-
// if (obj[key] > tmp) {
74-
// tmp = obj[key]
75-
// }
76-
// }
77-
// return tmp
78-
// }
79-
80-
81-
// console.log(getMax(conuntStr(str)))
82-
// console.log(conuntStr(str))
83-
84-
85-
// //请写出以下js的输出内容
86-
// async function async1() {
87-
// console.log('async1 start');
88-
// await async2();
89-
// console.log('async1 end');
90-
// }
91-
// async function async2() {
92-
// console.log('async2');
93-
// }
94-
95-
// console.log('script start');
96-
97-
// setTimeout(function () {
98-
// console.log('setTimeout');
99-
// }, 0)
100-
101-
// new Promise(function (resolve) {
102-
// console.log('promise1');
103-
// resolve();
104-
// }).then(function () {
105-
// console.log('promise2');
106-
// });
107-
108-
// async1();
109-
110-
// console.log('script end');
111-
112-
113-
114-
115-
116-
117-
var a = 10;
118-
119-
(function () {
120-
console.log(a)
121-
a = 20
122-
console.log(window.a)
123-
124-
console.log(a)
125-
})()
126-
127-
</script>
128-
</body>
129-
130-
=======
1311
<!DOCTYPE html>
1322
<html lang="en">
1333

@@ -256,5 +126,4 @@
256126
</script>
257127
</body>
258128

259-
>>>>>>> 46e5d654750168326619cd5ec4cf48a1c0506d86
260129
</html>

0 commit comments

Comments
 (0)