{"id":37369,"date":"2025-05-15T22:28:02","date_gmt":"2025-05-15T14:28:02","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/37369.html"},"modified":"2025-05-15T22:28:02","modified_gmt":"2025-05-15T14:28:02","slug":"%e3%80%90%e9%9d%a2%e8%af%95-%c2%b7-%e4%b8%89%e3%80%91react%e5%a4%a7%e9%9b%86%e5%90%88%ef%bc%88%e7%b1%bb%e5%bc%8f-%e5%87%bd%e6%95%b0%e5%bc%8f%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/37369.html","title":{"rendered":"\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E7%B1%BB%E5%BC%8F%E7%BB%84%E4%BB%B6%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F-toc\" style=\"margin-left:0px\">\u7c7b\u5f0f\u7ec4\u4ef6\u751f\u547d\u5468\u671f<\/p>\n<p id=\"%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BB%84%E4%BB%B6hook-toc\" style=\"margin-left:0px\">\u51fd\u6570\u5f0f\u7ec4\u4ef6hook<\/p>\n<p id=\"%E7%BB%84%E4%BB%B6%E9%80%9A%E4%BF%A1-toc\" style=\"margin-left:0px\">\u7ec4\u4ef6\u901a\u4fe1<\/p>\n<p id=\"articleContentId-toc\" style=\"margin-left:0px\">\u7c7b\u7ec4\u4ef6\u548c\u51fd\u6570\u7ec4\u4ef6\u7684\u533a\u522b<\/p>\n<p id=\"%E5%85%A8%E5%B1%80%E7%8A%B6%E6%80%81%E7%AE%A1%E7%90%86react-redux-toc\" style=\"margin-left:0px\">\u5168\u5c40\u72b6\u6001\u7ba1\u7406react-redux<\/p>\n<p id=\"%E8%B7%AF%E7%94%B1-toc\" style=\"margin-left:0px\">\u8def\u7531<\/p>\n<p id=\"wkUcC-toc\" style=\"margin-left:0px\">\u53d7\u63a7\u7ec4\u4ef6\u548c\u975e\u53d7\u63a7\u7ec4\u4ef6<\/p>\n<p id=\"%E9%AB%98%E9%98%B6%E7%BB%84%E4%BB%B6-toc\" style=\"margin-left:0px\">\u9ad8\u9636\u7ec4\u4ef6<\/p>\n<p id=\"OPutc-toc\" style=\"margin-left:0px\">Fiber<\/p>\n<h2 id=\"%E7%B1%BB%E5%BC%8F%E7%BB%84%E4%BB%B6%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F\">\u7c7b\u5f0f\u7ec4\u4ef6\u751f\u547d\u5468\u671f<\/h2>\n<p><span style=\"color:#be191c\">constructor<\/span><\/p>\n<p>\u521d\u59cb\u5316\u7ec4\u4ef6\u7684\u72b6\u6001\u548c\u7ed1\u5b9a\u4e8b\u4ef6\u5904\u7406\u5668\u3002<\/p>\n<p>constructor(props) {<br \/>\n  super(props);<br \/>\n  this.state &#061; { count: 0 };<br \/>\n  this.handleClick &#061; this.handleClick.bind(this); \/\/ \u7ed1\u5b9a\u4e8b\u4ef6\u5904\u7406\u5668<br \/>\n} <\/p>\n<p><span style=\"color:#be191c\">getDerivedStateFromProps<\/span><\/p>\n<p>\u7528\u4e8e\u5728\u6302\u8f7d\u548c\u66f4\u65b0\u524d\u6839\u636e props \u66f4\u65b0 state\u3002<\/p>\n<p>static getDerivedStateFromProps(nextProps, prevState) {<br \/>\n  if (nextProps.value !&#061;&#061; prevState.value) {<br \/>\n    return { value: nextProps.value };<br \/>\n  }<br \/>\n  return null;<br \/>\n} <\/p>\n<p><span style=\"color:#be191c\">render<\/span><\/p>\n<p>\u5fc5\u987b\u5b9e\u73b0\u7684\u65b9\u6cd5&#xff0c;\u6e32\u67d3\u7ec4\u4ef6\u7684\u865a\u62df DOM\u3002<\/p>\n<p><span style=\"color:#be191c\">componentDidMount<\/span><\/p>\n<p>\u7ec4\u4ef6\u6302\u8f7d\u5b8c\u6210\u540e\u8c03\u7528&#xff0c;\u901a\u5e38\u7528\u4e8e\u53d1\u8d77\u7f51\u7edc\u8bf7\u6c42\u3001\u8ba2\u9605\u4e8b\u4ef6\u7b49\u526f\u4f5c\u7528\u64cd\u4f5c\u3002<\/p>\n<p>componentDidMount() {<br \/>\n  fetch(&#039;\/api\/data&#039;).then(response &#061;&gt; this.setState({ data: response.data }));<br \/>\n} <\/p>\n<p><span style=\"color:#be191c\">shouldComponentUpdate<\/span><\/p>\n<p>\u5224\u65ad\u7ec4\u4ef6\u662f\u5426\u9700\u8981\u91cd\u65b0\u6e32\u67d3\u3002\u8fd4\u56de\u00a0false\u00a0\u53ef\u4ee5\u963b\u6b62\u4e0d\u5fc5\u8981\u7684\u91cd\u65b0\u6e32\u67d3\u3002<\/p>\n<p>shouldComponentUpdate(nextProps, nextState) {<br \/>\n  return nextState.count !&#061;&#061; this.state.count;<br \/>\n} <\/p>\n<p><span style=\"color:#be191c\">getSnapshotBeforeUpdate<\/span><\/p>\n<p>\u5728\u6700\u65b0\u7684\u6e32\u67d3\u8f93\u51fa\u63d0\u4ea4\u7ed9 DOM \u4e4b\u524d\u8c03\u7528&#xff0c;\u53ef\u4ee5\u6355\u83b7\u4e00\u4e9b DOM \u4fe1\u606f&#xff08;\u5982\u6eda\u52a8\u4f4d\u7f6e&#xff09;&#xff0c;\u4ee5\u4fbf\u5728\u00a0componentDidUpdate\u00a0\u4e2d\u4f7f\u7528\u3002<\/p>\n<p>getSnapshotBeforeUpdate(prevProps, prevState) {<br \/>\n  if (prevProps.items.length &lt; this.props.items.length) {<br \/>\n    return this.listRef.scrollHeight;<br \/>\n  }<br \/>\n  return null;<br \/>\n} <\/p>\n<p><span style=\"color:#be191c\">componentDidUpdate<\/span><\/p>\n<p>\u7ec4\u4ef6\u66f4\u65b0\u5b8c\u6210\u540e\u8c03\u7528&#xff0c;\u53ef\u4ee5\u5728\u6b64\u8fdb\u884c\u526f\u4f5c\u7528\u64cd\u4f5c&#xff08;\u5982\u7f51\u7edc\u8bf7\u6c42\u3001DOM \u64cd\u4f5c\u7b49&#xff09;<\/p>\n<p>\u53ef\u4ee5\u8c03\u7528 setState()&#xff0c;\u4f46\u5fc5\u987b\u5305\u88f9\u5728\u6761\u4ef6\u8bed\u53e5\u4e2d&#xff0c;\u5426\u5219\u4f1a\u5bfc\u81f4\u65e0\u9650\u5faa\u73af<\/p>\n<p>componentDidUpdate(prevProps, prevState, snapshot) {<\/p>\n<p>} <\/p>\n<p><span style=\"color:#be191c\">componentWillUnmount<\/span><\/p>\n<p>\u7ec4\u4ef6\u5378\u8f7d\u548c\u9500\u6bc1\u4e4b\u524d\u8c03\u7528&#xff0c;\u901a\u5e38\u7528\u4e8e\u6e05\u7406\u5de5\u4f5c&#xff0c;\u5982\u53d6\u6d88\u8bf7\u6c42\u3001\u6e05\u9664\u5b9a\u65f6\u5668\u3001\u79fb\u9664\u76d1\u542c\u5668\u7b49\u3002<\/p>\n<p>componentWillUnmount() {<br \/>\n  clearInterval(this.timerID);<br \/>\n  this.subscription.remove();<br \/>\n} <\/p>\n<p><span style=\"color:#be191c\">\u9519\u8bef\u8fb9\u754c<\/span><\/p>\n<p> static getDerivedStateFromError(error) {<br \/>\n    \/\/ \u66f4\u65b0 state \u4ee5\u89e6\u53d1\u5907\u7528 UI \u7684\u6e32\u67d3<br \/>\n    return { hasError: true };<br \/>\n }  <\/p>\n<p> componentDidCatch(error, errorInfo) {<br \/>\n    \/\/ \u4f60\u53ef\u4ee5\u5c06\u9519\u8bef\u65e5\u5fd7\u4e0a\u62a5\u7ed9\u670d\u52a1\u5668<br \/>\n    console.error(&#034;Uncaught error:&#034;, error, errorInfo);<br \/>\n } <\/p>\n<h2 id=\"%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BB%84%E4%BB%B6hook\">\u51fd\u6570\u5f0f\u7ec4\u4ef6hook<\/h2>\n<p><span style=\"color:#be191c\">useState<\/span><\/p>\n<p>\u72b6\u6001\u7ba1\u7406\u00a0\u00a0\u8fd4\u56de\u4e00\u4e2a\u72b6\u6001\u503c\u548c\u66f4\u65b0\u51fd\u6570<\/p>\n<p>import React,{ useState } from &#039;react&#039;<br \/>\nconst [xxx, setXxx] &#061; useState(  ) <\/p>\n<p><span style=\"color:#be191c\">useEffect<\/span><\/p>\n<\/p>\n<p>\u7ec4\u5408\u4e86 componentDidMount, componentDidUpdate \u548c componentWillUnmount\u00a0<\/p>\n<p>useEffect(() &#061;&gt; {<br \/>\n     \u5728return\u4e0a\u9762\u53ef\u4ee5\u6267\u884c\u4efb\u4f55\u5e26\u526f\u4f5c\u7528\u64cd\u4f5c<br \/>\n    return () &#061;&gt; {  \u5728\u7ec4\u4ef6\u5378\u8f7d\u524d\u6267\u884c<br \/>\n     \u5728\u6b64\u505a\u4e00\u4e9b\u6536\u5c3e\u5de5\u4f5c, \u6bd4\u5982\u6e05\u9664\u5b9a\u65f6\u5668\/\u53d6\u6d88\u8ba2\u9605\u7b49<br \/>\n    }<br \/>\n}, [stateValue])  \u5982\u679c\u6307\u5b9a\u7684\u662f[], \u56de\u8c03\u51fd\u6570\u53ea\u4f1a\u5728\u7b2c\u4e00\u6b21render()\u540e\u6267\u884c <\/p>\n<p><span style=\"color:#be191c\">useLayoutEffect<\/span><\/p>\n<p>\u7528\u4e8e\u5728\u6d4f\u89c8\u5668\u91cd\u65b0\u7ed8\u5236\u5c4f\u5e55\u4e4b\u524d\u89e6\u53d1<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"161\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515142800-6825f9f0ce6ba.png\" width=\"674\" \/><\/p>\n<p><span style=\"color:#be191c\">useContext<\/span><\/p>\n<p>\u8ba2\u9605React\u4e0a\u4e0b\u6587<\/p>\n<p>const value &#061; useContext(MyContext);<br \/>\n\/\/ 1. \u521b\u5efa\u4e0a\u4e0b\u6587<br \/>\nconst ThemeContext &#061; createContext(&#039;light&#039;);<\/p>\n<p>\/\/ 2. \u63d0\u4f9b\u4e0a\u4e0b\u6587<br \/>\nconst App &#061; () &#061;&gt; (<br \/>\n  &lt;ThemeContext.Provider value&#061;&#034;dark&#034;&gt;<br \/>\n    &lt;Child \/&gt;<br \/>\n  &lt;\/ThemeContext.Provider&gt;<br \/>\n);<\/p>\n<p>\/\/ 3. \u4f7f\u7528\u4e0a\u4e0b\u6587<br \/>\nconst Child &#061; () &#061;&gt; {<br \/>\n  const theme &#061; useContext(ThemeContext);<br \/>\n  return &lt;div&gt;Theme: {theme}&lt;\/div&gt;;<br \/>\n}; <\/p>\n<p><span style=\"color:#be191c\">useRef<\/span><\/p>\n<p>\u5728\u51fd\u6570\u7ec4\u4ef6\u4e2d\u5b58\u50a8\/\u67e5\u627e\u7ec4\u4ef6\u5185\u7684\u6807\u7b7e\u6216\u4efb\u610f\u5176\u5b83\u6570\u636e<\/p>\n<p>const myRef &#061; React.useRef()<\/p>\n<p>function show(){<br \/>\n    alert(myRef.current.value)<br \/>\n}<\/p>\n<p>&lt;input type&#061;&#034;text&#034; ref&#061;{myRef}\/&gt;<br \/>\n&lt;button onClick&#061;{show}&gt;\u70b9\u6211\u63d0\u793a\u6570\u636e&lt;\/button&gt; <\/p>\n<p><span style=\"color:#be191c\">useMemo \u548c useCallback<\/span><\/p>\n<p>\u76f8\u5f53\u4e8e shouldComponentUpdate \u7684\u4f18\u5316&#xff0c;\u7528\u4e8e\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u8ba1\u7b97\u548c\u6e32\u67d3<\/p>\n<p>useMemo \u548c useCallback<\/p>\n<p><span style=\"color:#be191c\">useReducer<\/span><\/p>\n<p>useReducer (redux)<\/p>\n<\/p>\n<p>useReducer \u662f React Hooks \u4e2d\u7684\u4e00\u4e2a\u51fd\u6570&#xff0c;\u7528\u4e8e\u7ba1\u7406\u548c\u66f4\u65b0\u7ec4\u4ef6\u7684\u72b6\u6001\u3002\u5b83\u53ef\u4ee5\u88ab\u89c6\u4e3a useState \u7684\u4e00\u79cd\u66ff\u4ee3\u65b9\u6848&#xff0c;\u9002\u7528\u4e8e\u5904\u7406\u66f4\u590d\u6742\u7684\u72b6\u6001\u903b\u8f91\u3002<\/p>\n<p>\u76f8\u6bd4\u4e8e useState&#xff0c;useReducer \u5728\u5904\u7406\u590d\u6742\u72b6\u6001\u903b\u8f91\u65f6\u66f4\u6709\u4f18\u52bf&#xff0c;\u56e0\u4e3a\u5b83\u5141\u8bb8\u6211\u4eec\u5c06\u72b6\u6001\u66f4\u65b0\u7684\u903b\u8f91\u5c01\u88c5\u5728 reducer \u51fd\u6570\u4e2d&#xff0c;\u5e76\u6839\u636e\u4e0d\u540c\u7684\u52a8\u4f5c\u7c7b\u578b\u6267\u884c\u76f8\u5e94\u7684\u903b\u8f91\u3002\u8fd9\u6837\u53ef\u4ee5\u4f7f\u4ee3\u7801\u66f4\u5177\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027&#xff0c;\u5e76\u4e14\u66f4\u5bb9\u6613\u8fdb\u884c\u72b6\u6001\u8ffd\u8e2a\u548c\u8c03\u8bd5\u3002<\/p>\n<p>import { useReducer } from &#039;react&#039;;<\/p>\n<p>const initialState &#061; {<br \/>\n  count: 0,<br \/>\n};<\/p>\n<p>const reducer &#061; (state, action) &#061;&gt; {<br \/>\n  switch (action.type) {<br \/>\n    case &#039;increment&#039;:<br \/>\n      return { count: state.count &#043; 1 };<br \/>\n    case &#039;decrement&#039;:<br \/>\n      return { count: state.count &#8211; 1 };<br \/>\n    default:<br \/>\n      throw new Error(&#039;Unsupported action type&#039;);<br \/>\n  }<br \/>\n};<\/p>\n<p>function Counter() {<br \/>\n  const [state, dispatch] &#061; useReducer(reducer, initialState);<\/p>\n<p>  const increment &#061; () &#061;&gt; {<br \/>\n    dispatch({ type: &#039;increment&#039; });<br \/>\n  };<\/p>\n<p>  const decrement &#061; () &#061;&gt; {<br \/>\n    dispatch({ type: &#039;decrement&#039; });<br \/>\n  };<\/p>\n<p>  return (<br \/>\n    &lt;div&gt;<br \/>\n      &lt;p&gt;Count: {state.count}&lt;\/p&gt;<br \/>\n      &lt;button onClick&#061;{increment}&gt;Increment&lt;\/button&gt;<br \/>\n      &lt;button onClick&#061;{decrement}&gt;Decrement&lt;\/button&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  );<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"403\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515142800-6825f9f0f2de5.png\" width=\"428\" \/><\/p>\n<h2 id=\"%E7%BB%84%E4%BB%B6%E9%80%9A%E4%BF%A1\">\u7ec4\u4ef6\u901a\u4fe1<\/h2>\n<p>\u7236\u4f20\u5b50<\/p>\n<p>\/\/\u7c7b\u5f0f\u7ec4\u4ef6\u2014\u2014\u2014\u2014\u7236<br \/>\nimport React, { Component } from &#039;react&#039;<br \/>\nimport Son from &#039;.\/Son&#039;<\/p>\n<p>export default class Parent extends Component {<br \/>\n  state &#061; {<br \/>\n    info: &#039;\u6211\u662f\u7236\u7ec4\u4ef6\u8981\u4f20\u7ed9\u5b50\u7ec4\u4ef6\u7684\u6570\u636e&#xff01;&#039;<br \/>\n  }<br \/>\n  render() {<br \/>\n    const { info } &#061; this.state<br \/>\n    return (<br \/>\n      &lt;div &gt;<br \/>\n        &lt;h2&gt;\u4f60\u597d&#xff0c;\u6211\u662fParent\u7ec4\u4ef6&#xff01;&lt;\/h2&gt;<br \/>\n        {\/* \u7236\u7ec4\u4ef6\u901a\u8fc7\u5728\u5b50\u6807\u7b7e\u4e2d\u6dfb\u52a0 \u5c5e\u6027&#061;\u503c \u5c06\u6570\u636e\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6 *\/}<br \/>\n        &lt;Son info&#061;{info} \/&gt;<br \/>\n      &lt;\/div&gt;<br \/>\n    )<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/\u5b50<br \/>\nimport React, { Component } from &#039;react&#039;<\/p>\n<p>export default class Son extends Component {<br \/>\n  render() {<br \/>\n    const { info } &#061; this.props<br \/>\n    return (<br \/>\n      &lt;div &gt;<br \/>\n        &lt;h2&gt;\u4f60\u597d&#xff0c;\u6211\u662fSon\u7ec4\u4ef6&#xff01;&lt;\/h2&gt;<br \/>\n        &lt;h3&gt;\u6211\u63a5\u53d7\u5230\u7236\u7ec4\u4ef6\u4f20\u9012\u8fc7\u6765\u7684\u6570\u636e\u662f&#xff1a;{info}&lt;\/h3&gt;<br \/>\n      &lt;\/div&gt;<br \/>\n    )<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/\u51fd\u6570\u5f0f\u7ec4\u4ef6\u2014\u2014\u2014\u2014\u7236<br \/>\nimport React from &#039;react&#039;<br \/>\nimport Son from &#039;.\/Son&#039;<\/p>\n<p>export default function Parent() {<br \/>\n  const info &#061; &#039;\u6211\u662f\u7236\u7ec4\u4ef6\u8981\u4f20\u7ed9\u5b50\u7ec4\u4ef6\u7684\u6570\u636e&#xff01;&#039;<br \/>\n  return (<br \/>\n    &lt;div className&#061;&#039;parent&#039;&gt;<br \/>\n      &lt;h2&gt;\u4f60\u597d&#xff0c;\u6211\u662fParent\u7ec4\u4ef6&#xff01;&lt;\/h2&gt;<br \/>\n      {\/* \u7236\u7ec4\u4ef6\u901a\u8fc7\u5728\u5b50\u6807\u7b7e\u4e2d\u6dfb\u52a0 \u5c5e\u6027&#061;\u503c \u5c06\u6570\u636e\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6 *\/}<br \/>\n      &lt;Son info&#061;{info} \/&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  )<br \/>\n}<\/p>\n<p>\/\/\u5b50<br \/>\nimport React from &#039;react&#039;<\/p>\n<p>export default function Son(props) {<br \/>\n  const {info} &#061; props<br \/>\n  return (<br \/>\n    &lt;div &gt;<br \/>\n      &lt;h2&gt;\u4f60\u597d&#xff0c;\u6211\u662fSon\u7ec4\u4ef6&#xff01;&lt;\/h2&gt;<br \/>\n      &lt;h3&gt;\u6211\u63a5\u53d7\u5230\u7236\u7ec4\u4ef6\u4f20\u9012\u8fc7\u6765\u7684\u6570\u636e\u662f&#xff1a;{info}&lt;\/h3&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  )<br \/>\n}<\/p>\n<p>\u5b50\u4f20\u7236<\/p>\n<p>\/\/\u7c7b\u5f0f\u7ec4\u4ef6\u2014\u2014\u2014\u2014\u7236<br \/>\nimport React, { Component } from &#039;react&#039;<br \/>\nimport Son from &#039;.\/Son&#039;<br \/>\nimport &#039;.\/index.css&#039;<\/p>\n<p>export default class Parent extends Component {<br \/>\n  state &#061; {<br \/>\n    info: &#039;\u6211\u662f\u7236\u7ec4\u4ef6\u8981\u4f20\u7ed9\u5b50\u7ec4\u4ef6\u7684\u6570\u636e&#xff01;&#039;<br \/>\n  }<br \/>\n  changeInfo &#061; (info) &#061;&gt; {<br \/>\n    this.setState({ info })<br \/>\n  }<br \/>\n  render() {<br \/>\n    const { info } &#061; this.state<br \/>\n    return (<br \/>\n      &lt;div className&#061;&#039;parent&#039;&gt;<br \/>\n        &lt;h2&gt;\u4f60\u597d&#xff0c;\u6211\u662fParent\u7ec4\u4ef6&#xff01;&lt;\/h2&gt;<br \/>\n        {\/* \u7236\u7ec4\u4ef6\u7ed9\u5b50\u7ec4\u4ef6\u7ed1\u5b9a\u4e00\u4e2a\u56de\u8c03\u51fd\u6570changeInfo *\/}<br \/>\n        &lt;Son changeInfo&#061;{info &#061;&gt; { this.changeInfo(info) }} \/&gt;<br \/>\n        &lt;h3&gt;info\u4fe1\u606f\u662f&#xff1a;{info}&lt;\/h3&gt;<br \/>\n      &lt;\/div&gt;<br \/>\n    )<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/\u5b50<br \/>\nimport React, { Component } from &#039;react&#039;<\/p>\n<p>export default class Son extends Component {<br \/>\n  btnClick &#061; () &#061;&gt; {<br \/>\n    const info2 &#061; &#039;\u6211\u662f\u5b50\u7ec4\u4ef6\u6539\u53d8\u4e4b\u540e\u4f20\u7ed9\u7236\u7ec4\u4ef6\u7684\u6570\u636e&#xff01;&#039;<br \/>\n    this.props.changeInfo(info2 )<br \/>\n  }<br \/>\n  render() {<\/p>\n<p>    return (<br \/>\n      &lt;div className&#061;&#039;son&#039;&gt;<br \/>\n        &lt;h2&gt;\u4f60\u597d&#xff0c;\u6211\u662fSon\u7ec4\u4ef6&#xff01;&lt;\/h2&gt;<br \/>\n        &lt;button onClick&#061;{() &#061;&gt; this.btnClick()}&gt;\u70b9\u51fb\u6539\u53d8\u7236\u7ec4\u4ef6\u5c55\u793a\u7684info&lt;\/button&gt;<br \/>\n      &lt;\/div&gt;<br \/>\n    )<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/\u51fd\u6570\u5f0f\u7ec4\u4ef6\u2014\u2014\u2014\u2014\u7236<br \/>\nimport React, { useState } from &#039;react&#039;<br \/>\nimport Son from &#039;.\/Son&#039;<br \/>\nimport &#039;.\/index.css&#039;<\/p>\n<p>export default function Parent() {<br \/>\n  const [info, setInfo] &#061; useState(&#039;\u6211\u662f\u7236\u7ec4\u4ef6\u8981\u4f20\u7ed9\u5b50\u7ec4\u4ef6\u7684\u6570\u636e&#xff01;&#039;)<br \/>\n  function changeInfo(info) {<br \/>\n    setInfo(info)<br \/>\n  }<br \/>\n  return (<br \/>\n    &lt;div className&#061;&#039;parent&#039;&gt;<br \/>\n      &lt;h2&gt;\u4f60\u597d&#xff0c;\u6211\u662fParent\u7ec4\u4ef6&#xff01;&lt;\/h2&gt;<br \/>\n      {\/* \u7236\u7ec4\u4ef6\u7ed9\u5b50\u7ec4\u4ef6\u7ed1\u5b9a\u4e00\u4e2a\u56de\u8c03\u51fd\u6570changeInfo *\/}<br \/>\n      &lt;Son changeInfo&#061;{info &#061;&gt; changeInfo(info)} \/&gt;<br \/>\n      &lt;h3&gt;info\u4fe1\u606f\u662f&#xff1a;{info}&lt;\/h3&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  )<br \/>\n}<\/p>\n<p>\/\/\u5b50<br \/>\nimport React from &#039;react&#039;<\/p>\n<p>export default function Son(props) {<br \/>\n  function btnClick() {<br \/>\n    const info2 &#061; &#039;\u6211\u662f\u5b50\u7ec4\u4ef6\u6539\u53d8\u4e4b\u540e\u4f20\u7ed9\u7236\u7ec4\u4ef6\u7684\u6570\u636e&#xff01;&#039;<br \/>\n    props.changeInfo(info2)<br \/>\n  }<br \/>\n  return (<br \/>\n    &lt;div className&#061;&#039;son&#039;&gt;<br \/>\n      &lt;h2&gt;\u4f60\u597d&#xff0c;\u6211\u662fSon\u7ec4\u4ef6&#xff01;&lt;\/h2&gt;<br \/>\n      &lt;button onClick&#061;{btnClick}&gt;\u70b9\u51fb\u6539\u53d8\u7236\u7ec4\u4ef6\u5c55\u793a\u7684info&lt;\/button&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  )<br \/>\n}<\/p>\n<p>\u975e\u7236\u5b50\u901a\u4fe1 context<\/p>\n<p>\/\/\u7c7b\u5f0f\u7ec4\u4ef6\u2014\u2014\u2014\u2014\u7956\u7ec4\u4ef6<br \/>\nimport React, { Component } from &#039;react&#039;<br \/>\nimport Parent from &#039;.\/Parent&#039;<br \/>\nimport &#039;.\/index.css&#039;<\/p>\n<p>\/\/ \u521b\u5efa\u5e76\u66b4\u9732Context\u5bf9\u8c61<br \/>\nexport const { Provider, Consumer } &#061; React.createContext()<\/p>\n<p>export default class Grandpa extends Component {<br \/>\n  state &#061; { username: &#039;aDiao&#039;, age: 20 }<br \/>\n  changeMessage &#061; () &#061;&gt; {<br \/>\n    this.setState({ username: &#039;\u554a\u53fc&#039;, age: 18 })<br \/>\n  }<br \/>\n  render() {<br \/>\n    const { username, age } &#061; this.state<br \/>\n    return (<br \/>\n      &lt;div className&#061;&#039;grandpa&#039;&gt;<br \/>\n        &lt;h3&gt;\u6211\u662f\u7956\u7ec4\u4ef6&lt;\/h3&gt;<br \/>\n        &lt;h4&gt;\u6211\u7684\u7528\u6237\u540d\u662f&#xff1a;{username}&lt;\/h4&gt;<br \/>\n        &lt;h4&gt;\u6211\u7684\u5e74\u9f84\u662f&#xff1a;{age}&lt;\/h4&gt;<br \/>\n        &lt;button onClick&#061;{this.changeMessage}&gt;\u70b9\u6211\u66f4\u6539\u4fe1\u606f&lt;\/button&gt;<br \/>\n        &lt;Provider value&#061;{{ username, age }}&gt;<br \/>\n          &lt;Parent \/&gt;<br \/>\n        &lt;\/Provider&gt;<br \/>\n      &lt;\/div&gt;<br \/>\n    )<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/\u540e\u4ee3\u7ec4\u4ef6<br \/>\nimport React, { Component } from &#039;react&#039;<br \/>\n\/\/ \u5bfc\u5165Grandpa\u7ec4\u4ef6\u4e2d\u66b4\u9732\u51fa\u6765\u7684Context\u5bf9\u8c61\u7684Consumer<br \/>\nimport { Consumer } from &#039;.\/Grandpa&#039;<\/p>\n<p>export default class Son extends Component {<br \/>\n  render() {<br \/>\n    return (<br \/>\n      &lt;Consumer&gt;<br \/>\n        {<br \/>\n          (value) &#061;&gt; {<br \/>\n            return (&lt;div className&#061;&#039;son&#039; &gt;<br \/>\n              &lt;h3&gt;\u6211\u662f\u5b50\u7ec4\u4ef6&lt;\/h3&gt;<br \/>\n              &lt;h4&gt;\u6211\u63a5\u6536\u5230\u7684\u7528\u6237\u540d\u662f&#xff1a;{value.username}&lt;\/h4&gt;<br \/>\n              &lt;h4&gt;\u6211\u63a5\u6536\u5230\u7684\u5e74\u9f84\u662f&#xff1a;{value.age}&lt;\/h4&gt;<br \/>\n            &lt;\/div &gt;&#xff09;<br \/>\n          }<br \/>\n        }<br \/>\n      &lt;\/Consumer &gt;<\/p>\n<p>    )<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/\u51fd\u6570\u5f0f\u7ec4\u4ef6\u2014\u2014\u2014\u2014\u7956\u7ec4\u4ef6<br \/>\nimport React, { useState } from &#039;react&#039;<br \/>\nimport Parent from &#039;.\/Parent&#039;<br \/>\nimport &#039;.\/index.css&#039;<\/p>\n<p>export const { Provider, Consumer } &#061; React.createContext()<\/p>\n<p>export default function Grandpa() {<br \/>\n  const [user, setUser] &#061; useState({ username: &#039;aDiao&#039;, age: 20 })<br \/>\n  function changeMessage() {<br \/>\n    setUser({<br \/>\n      username: &#039;\u554a\u53fc&#039;,<br \/>\n      age: 18<br \/>\n    })<br \/>\n  }<br \/>\n  return (<br \/>\n    &lt;div className&#061;&#039;grandpa&#039;&gt;<br \/>\n      &lt;h3&gt;\u6211\u662f\u7956\u7ec4\u4ef6&lt;\/h3&gt;<br \/>\n      &lt;h4&gt;\u6211\u7684\u7528\u6237\u540d\u662f&#xff1a;{user.username}&lt;\/h4&gt;<br \/>\n      &lt;h4&gt;\u6211\u7684\u5e74\u9f84\u662f&#xff1a;{user.age}&lt;\/h4&gt;<br \/>\n      &lt;button onClick&#061;{changeMessage}&gt;\u70b9\u6211\u66f4\u6539\u4fe1\u606f&lt;\/button&gt;<br \/>\n      &lt;Provider value&#061;{user}&gt;<br \/>\n        &lt;Parent \/&gt;<br \/>\n      &lt;\/Provider&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  )<br \/>\n}<\/p>\n<p>\/\/\u540e\u4ee3\u7ec4\u4ef6<br \/>\nimport React from &#039;react&#039;<br \/>\nimport { Consumer } from &#039;.\/Grandpa&#039;<\/p>\n<p>export default function Son() {<br \/>\n  return (&lt;div className&#061;&#039;son&#039; &gt;<br \/>\n    &lt;h3&gt;\u6211\u662f\u5b50\u7ec4\u4ef6&lt;\/h3&gt;<br \/>\n    &lt;h4&gt;\u6211\u63a5\u6536\u5230\u7684\u7528\u6237\u540d\u662f&#xff1a;<br \/>\n      &lt;Consumer&gt;<br \/>\n        {value &#061;&gt; {<br \/>\n          return &#096;${value.username}&#096;<br \/>\n        }}<br \/>\n      &lt;\/Consumer&gt;<br \/>\n    &lt;\/h4&gt;<br \/>\n    &lt;h4&gt;\u6211\u63a5\u6536\u5230\u7684\u5e74\u9f84\u662f&#xff1a;<br \/>\n      &lt;Consumer&gt;<br \/>\n        {value &#061;&gt; {<br \/>\n          return &#096;${value.age}&#096;<br \/>\n        }}<br \/>\n      &lt;\/Consumer&gt;&lt;\/h4&gt;<br \/>\n  &lt;\/div &gt;)<br \/>\n}<\/p>\n<p>\u53d1\u5e03\u8ba2\u9605\u00a0pubsub<\/p>\n<p>\u6d88\u606f\u8ba2\u9605\u4e0e\u53d1\u5e03<\/p>\n<h2 id=\"articleContentId\">\u7c7b\u7ec4\u4ef6\u548c\u51fd\u6570\u7ec4\u4ef6\u7684\u533a\u522b<\/h2>\n<p>\u7c7b\u7ec4\u4ef6\u548c\u51fd\u6570\u5f0f\u7ec4\u4ef6\u7684\u533a\u522b<\/p>\n<h2 id=\"%E5%85%A8%E5%B1%80%E7%8A%B6%E6%80%81%E7%AE%A1%E7%90%86react-redux\">\u5168\u5c40\u72b6\u6001\u7ba1\u7406react-redux<\/h2>\n<p>redux<\/p>\n<h2 id=\"%E8%B7%AF%E7%94%B1\">\u8def\u7531<\/h2>\n<p>\u8def\u7531<\/p>\n<\/p>\n<p>\u8def\u7531\u4f20\u53c2<\/p>\n<h2 id=\"wkUcC\">\u53d7\u63a7\u7ec4\u4ef6\u548c\u975e\u53d7\u63a7\u7ec4\u4ef6<\/h2>\n<p>\u53d7\u63a7\u7ec4\u4ef6\u548c\u975e\u53d7\u63a7\u7ec4\u4ef6<\/p>\n<h2 id=\"%E9%AB%98%E9%98%B6%E7%BB%84%E4%BB%B6\">\u9ad8\u9636\u7ec4\u4ef6<\/h2>\n<p>\u81f3\u5c11\u6ee1\u8db3\u4e0b\u9762\u4e00\u4e2a\u6761\u4ef6<\/p>\n<p>\u00a0 \u00a0 \u00a0\u00a0 \u63a5\u53d7\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u51fd\u6570\u4f5c\u4e3a\u8f93\u5165<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u8f93\u51fa\u4e00\u4e2a\u51fd\u6570<\/p>\n<\/p>\n<p>\u9ad8\u9636\u7ec4\u4ef6<\/p>\n<h2 id=\"OPutc\">Fiber<\/h2>\n<p>React Fiber\u7b97\u6cd5\u662fReact 16\u4e2d\u5f15\u5165\u7684\u65b0\u7684diff\u7b97\u6cd5\u3002\u4e4b\u524d\u7684diff\u7b97\u6cd5(\u5373Stack Reconciler)\u662f\u9012\u5f52\u8c03\u7528,\u5728\u5904\u7406\u5927\u91cf\u5b50\u5143\u7d20\u65f6\u4f1a\u5bfc\u81f4\u6808\u6ea2\u51fa\u3002<\/p>\n<p>Fiber\u7b97\u6cd5\u57fa\u4e8e\u865a\u62dfDOM\u6811\u6765\u5bf9\u771f\u5b9eDOM\u6811\u8fdb\u884c\u589e\u91cf\u6e32\u67d3\u3002\u5b83\u5c06\u865a\u62dfDOM\u6811\u62c6\u5206\u6210\u591a\u4e2aFiber\u8282\u70b9,\u6bcf\u4e2aFiber\u8282\u70b9\u7ef4\u62a4\u81ea\u5df1\u7684\u72b6\u6001\u548c\u5b50\u6811\u3002<\/p>\n<p>Fiber\u89e3\u6790<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb927\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u7c7b\u5f0f\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u51fd\u6570\u5f0f\u7ec4\u4ef6hook\u7ec4\u4ef6\u901a\u4fe1\u7c7b\u7ec4\u4ef6\u548c\u51fd\u6570\u7ec4\u4ef6\u7684\u533a\u522b\u5168\u5c40\u72b6\u6001\u7ba1\u7406react-redux\u8def\u7531\u53d7\u63a7\u7ec4\u4ef6\u548c\u975e\u53d7\u63a7\u7ec4\u4ef6\u9ad8\u9636\u7ec4\u4ef6Fiber<\/p>\n","protected":false},"author":2,"featured_media":37367,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[723,524,87,885],"topic":[],"class_list":["post-37369","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-react","tag-react-js","tag-87","tag-885"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/37369.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb927\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u7c7b\u5f0f\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u51fd\u6570\u5f0f\u7ec4\u4ef6hook\u7ec4\u4ef6\u901a\u4fe1\u7c7b\u7ec4\u4ef6\u548c\u51fd\u6570\u7ec4\u4ef6\u7684\u533a\u522b\u5168\u5c40\u72b6\u6001\u7ba1\u7406react-redux\u8def\u7531\u53d7\u63a7\u7ec4\u4ef6\u548c\u975e\u53d7\u63a7\u7ec4\u4ef6\u9ad8\u9636\u7ec4\u4ef6Fiber\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/37369.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-15T14:28:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515142800-6825f9f0ce6ba.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/37369.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/37369.html\",\"name\":\"\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-15T14:28:02+00:00\",\"dateModified\":\"2025-05-15T14:28:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/37369.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/37369.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/37369.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/37369.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb927\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u7c7b\u5f0f\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u51fd\u6570\u5f0f\u7ec4\u4ef6hook\u7ec4\u4ef6\u901a\u4fe1\u7c7b\u7ec4\u4ef6\u548c\u51fd\u6570\u7ec4\u4ef6\u7684\u533a\u522b\u5168\u5c40\u72b6\u6001\u7ba1\u7406react-redux\u8def\u7531\u53d7\u63a7\u7ec4\u4ef6\u548c\u975e\u53d7\u63a7\u7ec4\u4ef6\u9ad8\u9636\u7ec4\u4ef6Fiber","og_url":"https:\/\/www.wsisp.com\/helps\/37369.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-15T14:28:02+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515142800-6825f9f0ce6ba.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/37369.html","url":"https:\/\/www.wsisp.com\/helps\/37369.html","name":"\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-15T14:28:02+00:00","dateModified":"2025-05-15T14:28:02+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/37369.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/37369.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/37369.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u9762\u8bd5 \u00b7 \u4e09\u3011react\u5927\u96c6\u5408\uff08\u7c7b\u5f0f\/\u51fd\u6570\u5f0f\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/37369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=37369"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/37369\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/37367"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=37369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=37369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=37369"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=37369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}