为了账号安全,请及时绑定邮箱和手机立即绑定

修改阿波罗反应函数以使用参数

修改阿波罗反应函数以使用参数

温温酱 2022-09-16 21:00:24
我目前正在 React 中使用这个函数:function GQLFunc() {  const { loading, error, data } = useQuery(GQLTAGS);  if (loading) return <p>Loading...</p>;  if (error) return <p>Error :(</p>;  if (data) return <WrappedApp data={data.tag} />;}我想用一个参数使这个函数可重用,所以尝试了:function GQLFunc(callingApp) {  const { loading, error, data } = useQuery(GQLTAGS);  if (loading) return <p>Loading...</p>;  if (error) return <p>Error :(</p>;  if (data) return <callingApp data={data.tag} />;}然后在这里调用它:<GQLFunc callingApp={WrappedApp} />我在这里做错了什么?我还想添加一个参数data = data.tag
查看完整描述

1 回答

?
慕森王

TA贡献1777条经验 获得超3个赞

您需要使用呈现的组件的大写名称,例如:


function GQLFunc(props) {

  const { loading, error, data } = useQuery(GQLTAGS);


  if (loading) return <p>Loading...</p>;

  if (error) return <p>Error :(</p>;


  let CallingApp = props.callingApp;

  if (data) return <CallingApp data={data.tag} />;

}


查看完整回答
反对 回复 2022-09-16
  • 1 回答
  • 0 关注
  • 62 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号