{"id":53224,"date":"2024-12-03T08:59:22","date_gmt":"2024-12-03T00:59:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53224\/"},"modified":"2024-12-03T08:59:22","modified_gmt":"2024-12-03T00:59:22","slug":"%e5%83%8f%e4%b8%93%e4%b8%9a%e4%ba%ba%e5%a3%ab%e4%b8%80%e6%a0%b7%e4%bd%bf%e7%94%a8-react-%e7%bb%84%e4%bb%b6%e4%bd%9c%e4%b8%ba-props-%e7%9a%84%e5%88%86%e6%ad%a5%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53224\/","title":{"rendered":"\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u4f7f\u7528 React \u7ec4\u4ef6\u4f5c\u4e3a Props \u7684\u5206\u6b65\u6307\u5357"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u4f7f\u7528 React \u7ec4\u4ef6\u4f5c\u4e3a Props \u7684\u5206\u6b65\u6307\u5357<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span>    <\/p>\n<p>\u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300a\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u4f7f\u7528 React \u7ec4\u4ef6\u4f5c\u4e3a Props \u7684\u5206\u6b65\u6307\u5357\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241128\/17327650116747e5537ff05.jpg\" class=\"aligncenter\" title=\"\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u4f7f\u7528 React \u7ec4\u4ef6\u4f5c\u4e3a Props \u7684\u5206\u6b65\u6307\u5357\u63d2\u56fe\" alt=\"\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u4f7f\u7528 React \u7ec4\u4ef6\u4f5c\u4e3a Props \u7684\u5206\u6b65\u6307\u5357\u63d2\u56fe\" \/><\/p>\n<h2> \u4ece\u521d\u5b66\u8005\u5230\u4e13\u4e1a\u4eba\u58eb\uff1a\u5c06 react \u7ec4\u4ef6\u7406\u89e3\u4e3a props <\/h2>\n<p>\u4f5c\u4e3a react \u5f00\u53d1\u4eba\u5458\uff0c\u60a8\u7ecf\u5e38\u4f1a\u9047\u5230\u9700\u8981\u5c06 react \u7ec4\u4ef6\u4f5c\u4e3a prop \u4f20\u9012\u7ed9\u53e6\u4e00\u4e2a\u7ec4\u4ef6\u7684\u60c5\u51b5\u3002\u8fd9\u9879\u6280\u672f\u53ef\u80fd\u975e\u5e38\u5f3a\u5927\uff0c\u4f46\u4e86\u89e3\u6b63\u786e\u7684\u65b9\u6cd5\u81f3\u5173\u91cd\u8981\uff0c\u4ee5\u907f\u514d\u5e38\u89c1\u7684\u9677\u9631\u3002\u5728\u8fd9\u4efd\u8be6\u7ec6\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c06\u63a2\u7d22\u4f7f\u7528 react \u7ec4\u4ef6\u4f5c\u4e3a props \u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u4ece\u57fa\u7840\u77e5\u8bc6\u5230\u9ad8\u7ea7\u7528\u4f8b\u3002<\/p>\n<h3> \u4e86\u89e3\u57fa\u7840\u77e5\u8bc6 <\/h3>\n<p>\u5728 react \u4e2d\uff0c\u7ec4\u4ef6\u53ef\u4ee5\u50cf\u4efb\u4f55\u5176\u4ed6\u6570\u636e\u7c7b\u578b\uff08\u4f8b\u5982\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u6216\u5bf9\u8c61\uff09\u4e00\u6837\u4f5c\u4e3a props \u4f20\u9012\u3002\u8fd9\u5141\u8bb8\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u5177\u6709\u9ad8\u5ea6\u7684\u7075\u6d3b\u6027\u548c\u53ef\u91cd\u7528\u6027\u3002<\/p>\n<p>\u8981\u5c06 react \u7ec4\u4ef6\u4f5c\u4e3a prop \u4f20\u9012\uff0c\u60a8\u53ea\u9700\u5c06\u8be5\u7ec4\u4ef6\u5206\u914d\u7ed9\u7236\u7ec4\u4ef6\u4e2d\u7684 prop\uff0c\u7136\u540e\u5728\u5b50\u7ec4\u4ef6\u4e2d\u4f7f\u7528\u8be5 prop\u3002\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre>\/\/ parent component\nimport childcomponent from '.\/childcomponent';\n\nconst parentcomponent = () =&gt; {\n  return &lt;childcomponent mycomponent={&lt;mycustomcomponent \/&gt;} \/&gt;;\n};\n\n\/\/ child component\nconst childcomponent = (props) =&gt; {\n  const mycomponent = props.mycomponent;\n  return &lt;mycomponent \/&gt;;\n};\n\n\/\/ custom component\nconst mycustomcomponent = () =&gt; {\n  return &lt;div&gt;this is a custom component!&lt;\/div&gt;;\n};\n<\/pre>\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0cparentcomponent \u5c06\u81ea\u5b9a\u4e49 mycustomcomponent \u4f5c\u4e3a mycomponent \u5c5e\u6027\u4f20\u9012\u7ed9 childcomponent\u3002\u7136\u540e\uff0cchildcomponent \u4f7f\u7528 mycomponent \u53d8\u91cf\u6e32\u67d3\u4f20\u9012\u7684\u7ec4\u4ef6\u3002<\/p>\n<h3> \u5904\u7406\u52a8\u6001\u7ec4\u4ef6 <\/h3>\n<p>\u5c06\u7ec4\u4ef6\u4f5c\u4e3a props \u4f20\u9012\u7684\u5f3a\u5927\u7528\u4f8b\u4e4b\u4e00\u662f\u6e32\u67d3\u52a8\u6001\u7ec4\u4ef6\u7684\u80fd\u529b\u3002\u8fd9\u610f\u5473\u7740\u4f20\u9012\u7684\u7ec4\u4ef6\u53ef\u4ee5\u6839\u636e\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u67d0\u4e9b\u6761\u4ef6\u6216\u72b6\u6001\u8fdb\u884c\u66f4\u6539\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528\u6b64\u6280\u672f\u7684\u793a\u4f8b\uff1a<\/p>\n<pre>\/\/ parent component\nimport { usestate } from 'react';\nimport dynamiccomponent from '.\/dynamiccomponent';\n\nconst parentcomponent = () =&gt; {\n  const [componenttype, setcomponenttype] = usestate('a');\n\n  const togglecomponent = () =&gt; {\n    setcomponenttype(componenttype === 'a' ? 'b' : 'a');\n  };\n\n  return (\n    &lt;div&gt;\n      &lt;button onclick={togglecomponent}&gt;toggle component&lt;\/button&gt;\n      &lt;dynamiccomponent component={componenttype === 'a' ? componenta : componentb} \/&gt;\n    &lt;\/div&gt;\n  );\n};\n\n\/\/ dynamic component\nconst dynamiccomponent = (props) =&gt; {\n  const component = props.component;\n  return &lt;component \/&gt;;\n};\n\n\/\/ custom components\nconst componenta = () =&gt; {\n  return &lt;div&gt;this is component a&lt;\/div&gt;;\n};\n\nconst componentb = () =&gt; {\n  return &lt;div&gt;this is component b&lt;\/div&gt;;\n};\n<\/pre>\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0cparentcomponent \u7ef4\u62a4\u4e00\u4e2a\u72b6\u6001\u53d8\u91cf componenttype\uff0c\u7528\u4e8e\u786e\u5b9a\u5728 dynamiccomponent \u4e2d\u6e32\u67d3\u54ea\u4e2a\u7ec4\u4ef6\u3002\u5f53\u5355\u51fb\u201ctoggle component\u201d\u6309\u94ae\u65f6\uff0c\u7ec4\u4ef6\u7c7b\u578b\u5c06\u88ab\u5207\u6362\uff0cdynamiccomponent \u5c06\u6839\u636e\u5176\u63a5\u6536\u5230\u7684 prop \u6e32\u67d3\u9002\u5f53\u7684\u7ec4\u4ef6\u3002<\/p>\n<h3> \u5c06 pros \u4f20\u9012\u7ed9\u5d4c\u5957\u7ec4\u4ef6 <\/h3>\n<p>\u5c06\u7ec4\u4ef6\u4f5c\u4e3a prop \u4f20\u9012\u65f6\uff0c\u60a8\u53ef\u80fd\u8fd8\u9700\u8981\u5c06\u5176\u4ed6 prop \u4f20\u9012\u7ed9\u5d4c\u5957\u7ec4\u4ef6\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5c06\u7ec4\u4ef6\u5305\u88c5\u5728\u4e00\u4e2a\u51fd\u6570\u4e2d\u6765\u5b8c\u6210\uff0c\u8be5\u51fd\u6570\u63a5\u53d7\u5fc5\u8981\u7684 props \u5e76\u8fd4\u56de\u8be5\u7ec4\u4ef6\u3002<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>\/\/ parent component\nimport childcomponent from '.\/childcomponent';\n\nconst parentcomponent = () =&gt; {\n  return &lt;childcomponent mycomponent={(props) =&gt; &lt;mycustomcomponent {...props} \/&gt;} \/&gt;;\n};\n\n\/\/ child component\nconst childcomponent = (props) =&gt; {\n  const mycomponent = props.mycomponent;\n  return &lt;mycomponent message=\"hello, world!\" \/&gt;;\n};\n\n\/\/ custom component\nconst mycustomcomponent = (props) =&gt; {\n  return &lt;div&gt;{props.message}&lt;\/div&gt;;\n};\n<\/pre>\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0cparentcomponent \u5c06\u4e00\u4e2a\u51fd\u6570\u4f5c\u4e3a mycomponent \u5c5e\u6027\u4f20\u9012\u7ed9 childcomponent\u3002\u8be5\u51fd\u6570\u91c7\u7528\u5fc5\u8981\u7684 props\uff08\u5728\u672c\u4f8b\u4e2d\u4e3a message props\uff09\u5e76\u8fd4\u56de\u5e26\u6709\u8fd9\u4e9b props \u7684 mycustomcomponent\u3002<\/p>\n<h3> \u8f6c\u53d1\u53c2\u8003\u6587\u732e <\/h3>\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5c06\u5f15\u7528\u8f6c\u53d1\u7ed9\u4f5c\u4e3a prop \u4f20\u9012\u7684\u7ec4\u4ef6\u3002\u8fd9\u53ef\u4ee5\u4f7f\u7528forwardref\u9ad8\u9636\u7ec4\u4ef6\u6765\u5b9e\u73b0\u3002<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>\/\/ parent component\nimport { useref } from 'react';\nimport childcomponent from '.\/childcomponent';\n\nconst parentcomponent = () =&gt; {\n  const myref = useref(null);\n\n  const handleclick = () =&gt; {\n    myref.current.focus();\n  };\n\n  return (\n    &lt;div&gt;\n      &lt;childcomponent mycomponent={forwardedcomponent} ref={myref} \/&gt;\n      &lt;button onclick={handleclick}&gt;focus input&lt;\/button&gt;\n    &lt;\/div&gt;\n  );\n};\n\n\/\/ child component\nconst childcomponent = forwardref((props, ref) =&gt; {\n  const mycomponent = props.mycomponent;\n  return &lt;mycomponent ref={ref} \/&gt;;\n});\n\n\/\/ forwarded component\nconst forwardedcomponent = forwardref((props, ref) =&gt; {\n  return &lt;input type=\"text\" ref={ref} \/&gt;;\n});\n<\/pre>\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0cparentcomponent \u5c06 forwardedcomponent \u4f5c\u4e3a prop \u4f20\u9012\u7ed9 childcomponent\u3002 childcomponent \u4f7f\u7528forwardref \u9ad8\u9636\u7ec4\u4ef6\u5c06ref \u8f6c\u53d1\u5230forwardedcomponent\u3002\u8fd9\u5141\u8bb8 parentcomponent \u901a\u8fc7\u8c03\u7528 ref \u4e0a\u7684 focus() \u65b9\u6cd5\u6765\u805a\u7126\u8f93\u5165\u5143\u7d20\u3002<\/p>\n<h3> \u8bb0\u4f4f\u4f20\u9012\u7684\u7ec4\u4ef6 <\/h3>\n<p>\u5c06\u7ec4\u4ef6\u4f5c\u4e3a prop \u4f20\u9012\u65f6\uff0c\u8003\u8651\u6027\u80fd\u5f71\u54cd\u975e\u5e38\u91cd\u8981\u3002\u5982\u679c\u4f20\u9012\u7684\u7ec4\u4ef6\u7684\u6e32\u67d3\u6210\u672c\u5f88\u9ad8\uff0c\u90a3\u4e48\u6700\u597d\u4f7f\u7528 react.memo \u9ad8\u9636\u7ec4\u4ef6\u6765\u8bb0\u5fc6\u5b83\u3002<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>\/\/ Parent Component\nimport { useState, memo } from 'react';\nimport ChildComponent from '.\/ChildComponent';\n\nconst ParentComponent = () =&gt; {\n  const [count, setCount] = useState(0);\n\n  const MemoizedMyComponent = memo(MyComponent);\n\n  return (\n    &lt;div&gt;\n      &lt;ChildComponent myComponent={&lt;MemoizedMyComponent count={count} \/&gt;} \/&gt;\n      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;\/button&gt;\n    &lt;\/div&gt;\n  );\n};\n\n\/\/ Child Component\nconst ChildComponent = (props) =&gt; {\n  const MyComponent = props.myComponent;\n  return &lt;MyComponent \/&gt;;\n};\n\n\/\/ Memoized Component\nconst MyComponent = ({ count }) =&gt; {\n  console.log('MyComponent rendered');\n  return &lt;div&gt;Count: {count}&lt;\/div&gt;;\n};\n<\/pre>\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0cparentcomponent \u4f7f\u7528 react.memo \u9ad8\u9636\u7ec4\u4ef6\u6765\u8bb0\u5fc6 mycomponent\u3002\u8fd9\u786e\u4fdd\u4e86 mycomponent \u4ec5\u5728\u5176 props \u66f4\u6539\u65f6\u91cd\u65b0\u6e32\u67d3\uff0c\u4ece\u800c\u63d0\u9ad8\u4e86\u5e94\u7528\u7a0b\u5e8f\u7684\u6574\u4f53\u6027\u80fd\u3002<\/p>\n<h3> \u7ed3\u8bba <\/h3>\n<p>\u5c06 react \u7ec4\u4ef6\u4f5c\u4e3a props \u4f20\u9012\u662f\u4e00\u9879\u5f3a\u5927\u7684\u6280\u672f\uff0c\u53ef\u4ee5\u8ba9\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u5177\u6709\u66f4\u5927\u7684\u7075\u6d3b\u6027\u548c\u53ef\u91cd\u7528\u6027\u3002\u901a\u8fc7\u9075\u5faa\u672c\u6307\u5357\u4e2d\u6982\u8ff0\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u4f7f\u7528\u6b64\u529f\u80fd\u6765\u521b\u5efa\u52a8\u6001\u3001\u9ad8\u6548\u4e14\u53ef\u6269\u5c55\u7684 react \u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u5728\u5c06\u7ec4\u4ef6\u4f5c\u4e3a props \u4f20\u9012\u65f6\uff0c\u8bf7\u8bb0\u4f4f\u8003\u8651\u6027\u80fd\u3001\u5f15\u7528\u8f6c\u53d1\u548c\u52a8\u6001\u7ec4\u4ef6\u6e32\u67d3\u7b49\u56e0\u7d20\u3002\u901a\u8fc7\u5bf9\u8fd9\u4e9b\u6982\u5ff5\u7684\u6df1\u5165\u7406\u89e3\uff0c\u60a8\u5c06\u80fd\u591f\u5f88\u597d\u5730\u638c\u63e1\u4f7f\u7528 react \u7ec4\u4ef6\u4f5c\u4e3a props \u7684\u827a\u672f\u3002<\/p>\n<p>\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300a\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u4f7f\u7528 React \u7ec4\u4ef6\u4f5c\u4e3a Props \u7684\u5206\u6b65\u6307\u5357\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n<p>      \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb\u5220\u9664    <\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   win10\u8fde\u4e0d\u4e0a\u7f51\u600e\u4e48\u529e\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u4f7f\u7528 React \u7ec4\u4ef6\u4f5c\u4e3a Props \u7684\u5206\u6b65\u6307\u5357 \u6536\u85cf \u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300a\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u4f7f\u7528 React \u7ec4\u4ef6\u4f5c\u4e3a Props \u7684\u5206\u6b65\u6307\u5357\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01 \u4ece\u521d\u5b66\u8005\u5230\u4e13\u4e1a\u4eba\u58eb\uff1a\u5c06 react \u7ec4\u4ef6\u7406\u89e3\u4e3a props \u4f5c\u4e3a react \u5f00\u53d1\u4eba\u5458\uff0c\u60a8\u7ecf\u5e38\u4f1a\u9047\u5230\u9700\u8981\u5c06 react \u7ec4\u4ef6\u4f5c\u4e3a prop \u4f20\u9012\u7ed9\u53e6\u4e00\u4e2a\u7ec4\u4ef6\u7684\u60c5\u51b5\u3002\u8fd9\u9879\u6280\u672f\u53ef\u80fd\u975e\u5e38\u5f3a\u5927\uff0c\u4f46\u4e86\u89e3\u6b63\u786e\u7684\u65b9\u6cd5\u81f3\u5173\u91cd\u8981\uff0c\u4ee5\u907f\u514d\u5e38\u89c1\u7684\u9677\u9631\u3002\u5728\u8fd9\u4efd\u8be6\u7ec6\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c06\u63a2\u7d22\u4f7f\u7528 react \u7ec4\u4ef6\u4f5c\u4e3a props \u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u4ece\u57fa\u7840\u77e5\u8bc6\u5230\u9ad8\u7ea7\u7528\u4f8b\u3002 \u4e86\u89e3\u57fa\u7840\u77e5\u8bc6 \u5728 react \u4e2d\uff0c\u7ec4\u4ef6\u53ef\u4ee5\u50cf\u4efb\u4f55\u5176\u4ed6\u6570\u636e\u7c7b\u578b\uff08\u4f8b\u5982\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u6216\u5bf9\u8c61\uff09\u4e00\u6837\u4f5c\u4e3a props \u4f20\u9012\u3002\u8fd9\u5141\u8bb8\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u5177\u6709\u9ad8\u5ea6\u7684\u7075\u6d3b\u6027\u548c\u53ef\u91cd\u7528\u6027\u3002 \u8981\u5c06 react \u7ec4\u4ef6\u4f5c\u4e3a prop \u4f20\u9012\uff0c\u60a8\u53ea\u9700\u5c06\u8be5\u7ec4\u4ef6\u5206\u914d\u7ed9\u7236\u7ec4\u4ef6\u4e2d\u7684 prop\uff0c\u7136\u540e\u5728\u5b50\u7ec4\u4ef6\u4e2d\u4f7f\u7528\u8be5 prop\u3002\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a \/\/ parent component import childcomponent from &#8216;.\/childcomponent&#8217;; const parentcomponent = () =&gt; { return &lt;childcomponent mycomponent={&lt;mycustomcomponent [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-53224","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53224"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53224\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}