React 学习之旅一
- 版本要求
Node >= 8.10 和 npm >= 5.6
node -v
npm -v
- 创建 React 项目
npx create-react-app my-app
- Hook
- 它可以让你在不编写 Class 的情况下使用 state 以及 React 其他的特性。
- 版本要求
React
版本大于等于v16.8.0
/React Native
从v0.59
开始支持
- 安装校验插件
eslint-plugin-react-hooks
npm install eslint-plugin-react-hooks --save-dev
- 或者
yarn add eslint-plugin-react-hooks --dev
- 配置如下
// package.json 文件下
"eslintConfig": {
"extends": "react-app",
"plugins": [
"react-hooks"
],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
},
- CSS 样式(使用
styled-components
)yarn add styled-components
- styled-components 官网
- 路径配置
- 配置绝对路径(在根目录下新增
jsconfig.json
文件) - 配置如下编码
- 配置绝对路径(在根目录下新增
// jsconfig.json
{
"compilerOptions": {
"baseUrl": "."
},
"include": [
"src"
]
}