START
import React,{Component} from 'react'
class Index extends Component {
constructor(props){
super(props);
this.state = {};
}
render() {
return (
<div>this is text</div>
)
}
}
- 只能有一個(gè)root tag
- 無論單個(gè)tag還是成對(duì)的tag都必須有閉合( / )
- class 必須首字母大寫( Index )
PropTypes
import React,{Component} from 'react'
import PropsTypes from 'prop-types'
class Index extends Component {
constructor(props){
super(props);
this.state = {};
}
render() {
return (
<div>this is text</div>
)
}
}
- import PropsTypes from 'prop-types'不要寫成 import React,{Component,PropTypes} from 'react' 這樣會(huì)警告,雖然不會(huì)報(bào)錯(cuò)(請(qǐng)養(yǎng)成好習(xí)慣)
- 驗(yàn)證類型請(qǐng)參考官網(wǎng)(官網(wǎng)很詳細(xì))
包管理工具 (自行轉(zhuǎn)官網(wǎng)文檔 start)
- react官網(wǎng)推薦的 create-react-app
- antd推薦的 dva
推薦學(xué)習(xí)資料 (自行百度)
- react小書
- react-router github
- redux 正在學(xué)習(xí)中...
UI 推薦 (目前只接觸過這兩個(gè))
注意
- 不論是看視頻還是看學(xué)習(xí)資料,有時(shí)發(fā)現(xiàn)自己的本地環(huán)境運(yùn)行不了,有可能是安裝的版本原因
- 這個(gè)時(shí)候看看package.json
- 如果有^,去掉后再安裝,或者直接安裝對(duì)應(yīng)版本號(hào)(不會(huì)去百度npm)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。