File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ import CoverButton from './test/CoverButton' ;
4+
5+ const el = (
6+ // 写在 组件中间{ }中的 会自动传入到 props.children
7+ < CoverButton >
8+ { {
9+ default : < h1 > default</ h1 > ,
10+ extra : < div > extra</ div >
11+ } }
12+ </ CoverButton >
13+ )
14+
15+
16+ const App = ( ) => el
17+ export default App
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+
3+ function Layout ( { children } ) {
4+ return < div > { children } </ div > ;
5+ }
6+
7+ Layout . Header = function Header ( { children } ) {
8+ return < header > { children } </ header > ;
9+ } ;
10+
11+ Layout . Footer = function Footer ( { children } ) {
12+ return < footer > { children } </ footer > ;
13+ } ;
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import Layout from './Layout'
3+
4+ export default ( ) => (
5+ < Layout >
6+ < Layout . Header >
7+ < h1 > Header</ h1 >
8+ </ Layout . Header >
9+
10+ < div > Main</ div >
11+
12+ < Layout . Footer >
13+ < p > Footer</ p >
14+ </ Layout . Footer >
15+ </ Layout >
16+ )
Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ import ReactDOM from 'react-dom';
2323// </>
2424// )
2525
26- import StateInEvent from './test/StateInEvent' ;
2726
2827// import { Btn, MyBtn } from './test/Event';
2928
@@ -51,10 +50,12 @@ import StateInEvent from './test/StateInEvent';
5150// </>
5251// )
5352
54- import AppOldLifeCylcle from './test/AppOldLifeCylcle'
53+ // import AppOldLifeCylcle from './test/AppOldLifeCylcle'
5554
56- const el = (
57- < AppOldLifeCylcle />
58- )
55+ // const el = (
56+ // <AppOldLifeCylcle />
57+ // )
58+
59+ import App from './App'
5960
60- ReactDOM . render ( el , document . getElementById ( 'root' ) )
61+ ReactDOM . render ( < App /> , document . getElementById ( 'root' ) )
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+
3+ function CoverButton ( props ) {
4+ return (
5+ < div >
6+ < button > { props . children . default } </ button >
7+ < h1 > { props . children . extra } </ h1 >
8+ </ div >
9+ )
10+ }
11+
12+ export default CoverButton
You can’t perform that action at this time.
0 commit comments