随笔分类 -  react学习

摘要:创建react项目 npx create-react-app my-app cd my-app npm start setState是异步的。 想要实现同步执行的效果,需要对其传参数为函数。 state和props的区别: 首先两者都是js对象,都是用来保存信息的,这些信息可以控制组件的渲染和输出, 阅读全文
posted @ 2022-01-17 10:38 阿兰儿 阅读(53) 评论(0) 推荐(0)
摘要:如何在函数组件中实现条件渲染呢? 列表渲染 list提前使用list, setList 和useState,hooks进行设置初始值。在return函数中编写列表渲染 <ul> {list.map(item => <li key={item}>{item}</li> )} </ul> 条件渲染 : 阅读全文
posted @ 2022-01-11 20:15 阿兰儿 阅读(1063) 评论(0) 推荐(0)
摘要:react的状态组件 react的有state的为状态组件,创建形式为: import React, { Component } from "react"; import './index.css' //有状态的组件 即有state //jsx语句 class Box extends Compone 阅读全文
posted @ 2021-12-07 17:42 阿兰儿 阅读(55) 评论(0) 推荐(0)