react
文章平均质量分 55
前端小努力
这个作者很懒,什么都没留下…
展开
-
React-Redux使用方法
1.在React项目中使用react-redux,可以让你更方便的使用redux,原理是在index.js中注册app时用一个<Povider>标签嵌套,把你的App.js变Provideer的子组件,将所有的state以props的形式传给<App/>App.jsimport React, { Component } from "react";import About from "./pages/About"; //About是路由组件import { Provide原创 2022-01-08 11:57:15 · 4349 阅读 · 0 评论 -
React hook 10种 Hook
React Hook是什么?React官网是这么介绍的: Hook 是 React 16.8 的新增特性。它可以让你在不编写 class 的情况下使用 state 以及其他的 React 特性。完全可选的 你无需重写任何已有代码就可以在一些组件中尝试 Hook。但是如果你不想,你不必现在就去学习或使用 Hook。100% 向后兼容的 Hook 不包含任何破坏性改动。现在可用 Hook 已发布于 v16.8.0。没有计划从 React 中移除 class 你可以在本页底部的章节读到更多关于转载 2022-01-04 23:45:01 · 441 阅读 · 0 评论 -
react 使用context方式组件传参
第一步:引入调用React.createContext()得到context对象,在context对象中取出Providerconst MyContext = React.createContext()const {Provider} = MyContext第二步:发送数据在要发送数据的组件(A)中写入Provider,添加value属性,值为要传递的值,若有多个值则:value={undefined{username, password}}形式内部写入(A)的孩子组件(B)原创 2022-01-04 22:27:56 · 425 阅读 · 0 评论 -
搭建create-react-app并引入ant-design
重温一下怎么去搭建react项目!!安装 create-react-app先装脚手架npm install -g create-react-appyarn install -g create-react-appcreate-react-app myappnpm run start搭建好了..现在从 yarn 或 npm 安装并引入 antd.yarn add antd修改src/App.js,引入 antd 的按钮组件。import React...原创 2021-09-02 21:40:40 · 223 阅读 · 0 评论