This commit is contained in:
2022-01-17 00:28:49 +08:00
parent cc6c0df2ab
commit 8a4c8cb1e6
4 changed files with 59 additions and 4 deletions
+41
View File
@@ -0,0 +1,41 @@
<!--
* @Author: chenxuan
* @Date: 2022-01-15 19:51:19
* @LastEditTime: 2022-01-15 19:56:39
* @LastEditors: chenxuan
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app"></div>
<script src="../package/old/react.development.js"></script>
<script src="../package/old/react-dom.development.js"></script>
<script src="../package/old/babel.min.js"></script>
<script type="text/babel">
class Time extends React.Component{
state={date:new Date()}
render(){
return (
<div>
<h1>hello!</h1>
<input type="text"/>
<span>现在是:{this.state.date.toTimeString()}</span>
</div>
)
}
componentDidMount(){
setInterval(()=>{
this.setState({date:new Date()})
},1000)
}
}
ReactDOM.render(<Time/>,document.getElementById('app'))
</script>
</body>
</html>
+2
View File
@@ -0,0 +1,2 @@
1、diffing算法
2、循环时key的原理
+8 -1
View File
@@ -1,6 +1,13 @@
/*
* @Author: chenxuan
* @Date: 2021-11-21 15:55:16
* @LastEditTime: 2022-01-15 00:21:58
* @LastEditors: chenxuan
*/
import React from 'react'
import proxyHoc from './components/proxyHoc'
const Chenxuan=proxyHoc((props)=>{
console.log(props)
return(
<div>
<h1>{props.title}</h1>
@@ -17,7 +24,7 @@ class App extends React.Component{
render(){
return(
<div>
<Chenxuan title="xxxxx" id="66666"></Chenxuan>
<Chenxuan title="xxxxx1" id="66666" hehe="xxxx"></Chenxuan>
</div>
)
}
@@ -1,10 +1,16 @@
/*
* @Author: chenxuan
* @Date: 2021-11-21 15:55:16
* @LastEditTime: 2022-01-15 00:19:25
* @LastEditors: chenxuan
*/
import React from 'react'
function Hehe(WithComponent){
return class HocComponent extends React.Component{
constructor(){
super();
this.state={
userName:""
userName:"666"
}
}
setUsername(e){
@@ -17,9 +23,8 @@ function Hehe(WithComponent){
value:this.state.userName
}
};
console.log(this.props)
return(
<React.Fragment>
<li>{this.state.userName}</li>
<WithComponent