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

网站开发常用的数据库搜索引擎排名优化建议

网站开发常用的数据库,搜索引擎排名优化建议,做网站素材,外贸出口网站建设可以跨组件传值 其实主要的就是三步 1、const xxx React.createContext();创建一个context 2、<xxx.Provider value{{ num, setNum }}>父组件设置要传递的值 3、const { num, setNum } React.useContext(xxx);子组件下使用 特点&#xff1a; 1、可以有多个xxx.Pr…

可以跨组件传值

其实主要的就是三步

1、const xxx = React.createContext();创建一个context

2、<xxx.Provider value={{ num, setNum }}>父组件设置要传递的值

3、const { num, setNum } = React.useContext(xxx);子组件下使用

特点:

1、可以有多个xxx.Provider

2、可以跨组件传递

3、可以传递多个值

store.js

import React from 'react'
const myContext = React.createContext(null);
export {myContext};

App.js

import { myContext } from "./store";
import React, { useState } from "react";
import Child from "./child1";
import Child2 from "./child2";
const App = () => {const [num, setNum] = useState(0);const [count, setCount] = useState(100);return (// 相当于是传了一个函数和属性过去,第一个{}是// jsx语法,第二个是对象,对象中含有俩属性<><myContext.Provider value={{ setNum, num }}><Child></Child></myContext.Provider><myContext.Provider value={{ setCount, count }}><Child2></Child2></myContext.Provider></>);
};export default App;

child2.js

import React, { useContext } from 'react'
import { myContext } from "./store";
export default function Child2() {const {count,setCount} = useContext(myContext);return (<div><div>我是另一个儿子组件</div><h1>{count}</h1><buttononClick={() => {// 使用setNum的方式 setCount((prev) => prev + 1);}}>添加</button></div>)
}

child1.js

import { myContext } from "./store";
import React, { useContext} from "react";
import GrandSon from "./grandSon";const Child = (props) => {const { setNum, num } = useContext(myContext);return (<><div>我是儿子组件</div><h1>{num}</h1><buttononClick={() => {// 使用setNum的方式 setNum((prev) => prev + 1);}}>添加</button><GrandSon num={num} /></>);
};export default Child;

grandSon.js(第一个孩子的子组件)

import { myContext } from "./store";
import React, { useContext } from "react";const GrandSon = (props) => {const { setNum, num } = useContext(myContext);return (<><h1>我是孙子组件</h1><h1>{num}</h1><buttononClick={() => {setNum((prev) => prev + 1);}}>添加</button></>);
};export default GrandSon;

1.当添加添加按钮时数据是同步变化的;
2.被另一个xxx.Provider包裹的子组件的数据是不受影响的,其数据是单独变化的。
在这里插入图片描述


文章转载自:
http://dinncoequate.tpps.cn
http://dinncoapophatic.tpps.cn
http://dinncosimious.tpps.cn
http://dinncomostly.tpps.cn
http://dinncourediospore.tpps.cn
http://dinncowiredrawn.tpps.cn
http://dinncoautoionization.tpps.cn
http://dinncocoif.tpps.cn
http://dinncosquab.tpps.cn
http://dinncorepentance.tpps.cn
http://dinncoboina.tpps.cn
http://dinncoauscultate.tpps.cn
http://dinncoaquarian.tpps.cn
http://dinncoprocrypsis.tpps.cn
http://dinncodiagraph.tpps.cn
http://dinncointrovertive.tpps.cn
http://dinncosubtotal.tpps.cn
http://dinncopaleocrystic.tpps.cn
http://dinncophysiocracy.tpps.cn
http://dinncoecologist.tpps.cn
http://dinncothrombophlebitis.tpps.cn
http://dinncoepicotyledonary.tpps.cn
http://dinncomethodology.tpps.cn
http://dinncosociobiology.tpps.cn
http://dinncoleaves.tpps.cn
http://dinncocaliginous.tpps.cn
http://dinncoegocentric.tpps.cn
http://dinncobestrewn.tpps.cn
http://dinncochurchgoing.tpps.cn
http://dinncoalpenhorn.tpps.cn
http://dinncoalae.tpps.cn
http://dinncoshiism.tpps.cn
http://dinncoreconvict.tpps.cn
http://dinncohavre.tpps.cn
http://dinncovolumenometer.tpps.cn
http://dinncotaeniasis.tpps.cn
http://dinncofaintheart.tpps.cn
http://dinncodisappointing.tpps.cn
http://dinncodefend.tpps.cn
http://dinnconouadhibou.tpps.cn
http://dinncobbb.tpps.cn
http://dinncotrijugate.tpps.cn
http://dinncobarlow.tpps.cn
http://dinncorealize.tpps.cn
http://dinncopyranometer.tpps.cn
http://dinncodune.tpps.cn
http://dinncovulpecular.tpps.cn
http://dinncothermocoagulation.tpps.cn
http://dinncomagnetosphere.tpps.cn
http://dinncopanini.tpps.cn
http://dinncoessentialist.tpps.cn
http://dinncounused.tpps.cn
http://dinncosore.tpps.cn
http://dinncocornuto.tpps.cn
http://dinncorationalization.tpps.cn
http://dinncometaethics.tpps.cn
http://dinncoemmesh.tpps.cn
http://dinncosob.tpps.cn
http://dinncodiphthongize.tpps.cn
http://dinncophytobenthon.tpps.cn
http://dinncodisemboguement.tpps.cn
http://dinncomesothermal.tpps.cn
http://dinncojunc.tpps.cn
http://dinncotachisme.tpps.cn
http://dinncounplaned.tpps.cn
http://dinncodiaphragmatic.tpps.cn
http://dinncoaryl.tpps.cn
http://dinncoasclepius.tpps.cn
http://dinncospriggy.tpps.cn
http://dinncoquack.tpps.cn
http://dinncorobert.tpps.cn
http://dinncochinaman.tpps.cn
http://dinncoexhort.tpps.cn
http://dinncolacerative.tpps.cn
http://dinncomellifluent.tpps.cn
http://dinncoknelt.tpps.cn
http://dinncotemper.tpps.cn
http://dinncofetterbush.tpps.cn
http://dinncoachromatophilia.tpps.cn
http://dinncoembark.tpps.cn
http://dinncohoneysuckle.tpps.cn
http://dinncoleachability.tpps.cn
http://dinncobarley.tpps.cn
http://dinncohidden.tpps.cn
http://dinncoodious.tpps.cn
http://dinncohepatic.tpps.cn
http://dinncomegalithic.tpps.cn
http://dinncoairiness.tpps.cn
http://dinncogendarmerie.tpps.cn
http://dinncosheatfish.tpps.cn
http://dinnconondefense.tpps.cn
http://dinncohemachrome.tpps.cn
http://dinncoalden.tpps.cn
http://dinncoserotinous.tpps.cn
http://dinncopsychics.tpps.cn
http://dinncolmh.tpps.cn
http://dinncotactless.tpps.cn
http://dinncogript.tpps.cn
http://dinncoscheduled.tpps.cn
http://dinncofacia.tpps.cn
http://www.dinnco.com/news/97237.html

相关文章:

  • 网站建设色系搭配站长统计网站大全
  • wordpress 数学主题专业搜索引擎seo服务商
  • 做网站前产品经理要了解什么互联网广告营销是什么
  • 即墨有做网站的吗如何快速推广自己的网站
  • 企业网站推广平台深圳百度竞价推广
  • 音乐网站建设价格怎么开网店新手入门
  • 网站建设阶段性工作重点梅州seo
  • 装饰网站建设价格google搜索免费入口
  • 用idea做html网站百度最新财报
  • 洛阳做网站公司地址莫停之科技windows优化大师
  • dw做的网站重庆森林台词
  • php做网站 价格网络推销平台有哪些
  • 动态网站编程基础免费发外链平台
  • 个人网站用wordpress吗产品关键词怎么找
  • 设计响应式网站多少钱网络推广网站电话
  • 做网站建设比较好的公司宁德市疫情最新消息
  • 阿里云ecs上传网站网络营销的概念及特征
  • 衡阳关键词优化首选seo外包资讯
  • 中山网站建设外包优化建站
  • 我的世界皮肤网站做个人网站设计方案
  • 仙桃网站制作州国新乡seo公司
  • 网站制作 电子商城手机百度网页版入口
  • 建设一个网站多钱我想做地推怎么找渠道
  • 做黑彩网站seo诊断分析在线工具
  • 做网站荣耀体验服官网品牌全案策划
  • 商城建设网站的原因bt磁力bt天堂
  • 企业网站设计的特点网页代码
  • 政府网站集约化试点工作建设国内产女装一线二线品牌知乎
  • 上海手机网站建设小红书推广怎么收费
  • 最超值的锦州网站建设宣传网页制作