react
冬天爱吃冰淇淋
性别男,爱好女。
展开
-
React:styled-components的使用
styled-components的作用:用来在react中编写css样式,css in js1.安装yarn add styled-components2.styled-components基本使用index.jsimport React from 'react';import ReactDOM from 'react-dom';import App from './styled_component_test/01_styled_components复习';import { Theme原创 2020-10-24 12:52:25 · 261 阅读 · 0 评论 -
React学习:redux中间件
为什么redux需要中间件?因为我们redux中有很多数据需要异步请求,所以需要中间件帮助我们在redux中完成异步请求。1.redux-thunk中间件1.1安装yarn add redux-thunk1.2 在store中使用import { createStore, applyMiddleware } from 'redux'; // 导入应用中间件这个方法import reducer from './reducer';import thunkMiddleware from 'redu原创 2020-10-24 10:44:37 · 140 阅读 · 0 评论 -
React动画:react-transition-group的使用
1.安装yarn add react-transition-group2.使用CSSTransition组件import React, { PureComponent } from 'react';import { CSSTransition } from 'react-transition-group';import './CSSTransition.css'; // 导入css文件export default class App extends PureComponent { con原创 2020-10-23 13:13:28 · 235 阅读 · 0 评论 -
React中使用context来共享组件的数据
class组件中使用context:import React, { Component } from 'react';// 1. 生成一个Context,参数是共享变量的默认值const userContext = React.createContext({ nickName: 'aaa', age: -1,});class Banner extends Component { render() { return ( <div> // 4原创 2020-09-22 19:32:08 · 327 阅读 · 0 评论