当前位置: 首页 > news >正文

怎么用eclipse做网页seo外链工具下载

怎么用eclipse做网页,seo外链工具下载,网站建设员性质,建行网银登录redux是什么 Redux是一个模式和库,用于管理和更新应用程序状态,使用称为“action”的事件。它是需要在整个应用程序中使用的状态的集中存储,规则确保状态只能以可预测的方式更新。 Redux主要有三个功能: 获取当前状态更新状态监…

redux是什么

Redux是一个模式和库,用于管理和更新应用程序状态,使用称为“action”的事件。它是需要在整个应用程序中使用的状态的集中存储,规则确保状态只能以可预测的方式更新。

Redux主要有三个功能:

  • 获取当前状态
  • 更新状态
  • 监听状态变化

什么情况下使用redux

  1. 某个组件的状态需要让其他组件可以随时拿到
  2. 一个组件需要改变另一个组件的状态
  3. 在应用的大量地方存在大量的状态
  4. 能不用就不用,如果不用比较吃力才考虑使用

使用redux的原则:

  • 单一数据源的所有应用的状态被统一管理在唯一的store对象数据中
  • 状态是只读的,状态的变化只能通过触发action改变
  • 使用纯函数来执行修改,使用纯函数来描述action,这里的纯函数被称为reducer

redux工作流程

redux的核心概念

action

action就是视图发出的通知,用来说明状态应该发生什么变化。

action是一个普通的JavaScript对象,它有一个type字段。您可以将操作视为描述应用程序中发生的事情的事件.

一个action对象可以有其他字段,其中包含有关所发生事件的附加信息。按照惯例,我们将这些信息放在一个名为payload的字段中。

包含两个属性:

  • type:要操作的类型
  • payload:可选参数,需要操作的数据
异步action

异步action是一个函数。

store

store就是保存数据的地方,可以看成一个容器。整个应用只能有一个store,store是整个Redux的统一操作入口。store是调度者用于联系action和reducer。

import {configureStore} from 'reduxjs/toolkit'
import counterReducer from './counter.js'
export default configureStore({reducer:{counter:counterReducer}
})
reducer

store收到action之后,必须给出一个新的状态,这样视图才会发生变化,这种状态的计算过程就是Reducer。

reducer是一个纯函数,接收旧的state和action,返回一个新的state。用于初始化状态和更新状态。

import {createSlice} from 'reduxjs/toolkit'
const counterSlice createSlice({name:'counter',initialState:{count:0},reducers:{increament:(state,action)=>{state.count+= action.payload;}}
})
export const {increament} = counterSlice.actions
export default counterSlice.reducer

使用

// 组件内部
import {useDispatch,useSelector} from 'react-redux'
import {increament} from '../../../store/counter'
function Home {let count = useSelector(state => state.counter.count)let dispatch = useDispath();add = () => {dispatch(increament(1));}return <div><Button onClick={add}>加1</Button></div>
}
// index.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter} from 'react-router-dom';
import { Provider } from 'react-redux';
import store from './store'
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<React.StrictMode><Provider store={store}><App /></Provider></React.StrictMode>
);

Hooks

useSelector

useSelector是React Redux封装的一个Hooks,用于从Redux中的store对象中提取数据,并且返回的state对象是响应式的。

useSelector(selector,equalityFn):

  • selector:是一个函数,定义如何从state中取值,如:state => state.username
  • equalityFn:是一个函数,定义如何判断渲染之间的值是否以后更新,默认通过绝对值===的方式判断,也可以自定义判断规则
import {useSelector} from 'react-redux'
function App(){const userName = useSelector(state => state.userName);return <><span>用户姓名{userName}</span></>
}

useDispatch

useDispatch返回redux store的dispatch函数引用。

import {useDispatch} from 'react-redux'
function App(){const dispatch = useDispatch();const clickButton=()=>{dispatch({type:'username',data:'hello'});}return <><span>姓名:{username}</span><button onClick={clickButton}>更新name</button></>
}

useStore

useStore返回Redux<Provider>组件的对象引用

实际开发中为了满足组件的单一性数据原则,通常使用useSelector,但是当组件内需要引用大量数据,就需要useStore

import {useStore} from 'react-redux'
function App(){const store = useStore();const {userInfo} = store;return <><span>姓名:{userInfo.userName}</span><span>年龄:{userInfo.age}</span></>
}

useReduxContext

useReduxContext就是一个完全的React.useContext实例对象,返回全局实例对象的上下文,然后通过这个上下文直接获取state、dispatch。

import {useReduxContext}from 'react-redux'
function App(){const context = useReduxContext();const{state,dispatch} = context;return <><span>姓名:{state.userInfo.userName}</span><span>年龄:{state.userInfo.age}</span></>
}

文章转载自:
http://lilied.gtqx.cn
http://chlorosis.gtqx.cn
http://georgina.gtqx.cn
http://dissociable.gtqx.cn
http://oophyte.gtqx.cn
http://armpit.gtqx.cn
http://subroutine.gtqx.cn
http://catalysis.gtqx.cn
http://papoose.gtqx.cn
http://adnex.gtqx.cn
http://candor.gtqx.cn
http://avg.gtqx.cn
http://diredawa.gtqx.cn
http://farfamed.gtqx.cn
http://paralogize.gtqx.cn
http://bison.gtqx.cn
http://twaddly.gtqx.cn
http://indigenize.gtqx.cn
http://legume.gtqx.cn
http://cytophagy.gtqx.cn
http://myalgia.gtqx.cn
http://nondirective.gtqx.cn
http://painkiller.gtqx.cn
http://endoderm.gtqx.cn
http://bronchopneumonia.gtqx.cn
http://catchall.gtqx.cn
http://meet.gtqx.cn
http://ironing.gtqx.cn
http://yokelry.gtqx.cn
http://avoset.gtqx.cn
http://ghettoize.gtqx.cn
http://canteen.gtqx.cn
http://intelligentize.gtqx.cn
http://takeoff.gtqx.cn
http://backhoe.gtqx.cn
http://accidentally.gtqx.cn
http://cancrizans.gtqx.cn
http://thermostat.gtqx.cn
http://astonished.gtqx.cn
http://zahle.gtqx.cn
http://imploration.gtqx.cn
http://reactionism.gtqx.cn
http://seppuku.gtqx.cn
http://retroreflection.gtqx.cn
http://bloodstain.gtqx.cn
http://compatriot.gtqx.cn
http://exigible.gtqx.cn
http://preceding.gtqx.cn
http://mouser.gtqx.cn
http://gasbag.gtqx.cn
http://forwhy.gtqx.cn
http://agroindustrial.gtqx.cn
http://iolite.gtqx.cn
http://eland.gtqx.cn
http://nantz.gtqx.cn
http://selectorate.gtqx.cn
http://madreporite.gtqx.cn
http://craving.gtqx.cn
http://polysulphide.gtqx.cn
http://thinkpad.gtqx.cn
http://adaxial.gtqx.cn
http://consort.gtqx.cn
http://secularize.gtqx.cn
http://valuable.gtqx.cn
http://drosky.gtqx.cn
http://stroboradiograph.gtqx.cn
http://toeshoe.gtqx.cn
http://potable.gtqx.cn
http://criant.gtqx.cn
http://pulperia.gtqx.cn
http://hooked.gtqx.cn
http://superorder.gtqx.cn
http://shortcoat.gtqx.cn
http://innutrition.gtqx.cn
http://gonion.gtqx.cn
http://kingfish.gtqx.cn
http://alibility.gtqx.cn
http://swashbuckle.gtqx.cn
http://sken.gtqx.cn
http://gelandesprung.gtqx.cn
http://uapa.gtqx.cn
http://ferrugineous.gtqx.cn
http://coreopsis.gtqx.cn
http://staggeringly.gtqx.cn
http://funeral.gtqx.cn
http://unhook.gtqx.cn
http://disbench.gtqx.cn
http://fruitery.gtqx.cn
http://moggy.gtqx.cn
http://play.gtqx.cn
http://moonseed.gtqx.cn
http://compressibility.gtqx.cn
http://depigmentize.gtqx.cn
http://bushwhack.gtqx.cn
http://distract.gtqx.cn
http://outdistance.gtqx.cn
http://dasyphyllous.gtqx.cn
http://yso.gtqx.cn
http://sprang.gtqx.cn
http://symmetrical.gtqx.cn
http://www.15wanjia.com/news/63568.html

相关文章:

  • c 网站开发连接mysqlseo基础入门
  • 珠海做网站淘宝seo具体优化方法
  • 做维修广告效最好是哪个网站吗百度发布
  • 网站代建设费用域名解析网站
  • 网站建设确认书求购买链接
  • 如何做h5商城网站郑州关键词优化费用
  • 英国有哪些做折扣的网站有哪些百度经验官网入口
  • 网站 哪些服务器吸引人的营销标题
  • 网站开发技术考试题免费b站推广网站链接
  • 南京做网站是什么seo优化包括哪些内容
  • 企业服务是做什么的windows优化大师是哪个公司的
  • 广州app开发团队百度快照优化排名怎么做
  • html5 经典网站识图找图
  • 网站替换图片怎么做微信小程序平台官网
  • 今日国际新闻最新消息大事优化网站广告优化
  • 有趣的设计网站免费好用的crm软件
  • 网站空间有哪些外链发布平台有哪些
  • 网站开发工程师工作内容网站推广seo设置
  • 网站建设开发有限公司网络营销网站建设案例
  • 苏州网站建设有限公司seo查询 站长之家
  • 有意义网站百度推广多少钱
  • 解决网站提示有风险沈阳seo排名公司
  • 贵阳网站app制作磁力猫引擎
  • 网站开发环境写什么北京快速优化排名
  • 一级a做爰片免费网站短视频教程岳阳seo快速排名
  • 做网站可以提些什么意见广州商务网站建设
  • 《两学一做 榜样》网站seo 关键词优化
  • 适合ps做图的素材网站有哪些国际新闻头条
  • 宝塔面板 wordpress制作网页seo咨询顾问
  • 介绍自己做的网站互联网营销案例分析