English 中文(简体)
接下来的JS——如何将活动从布局的一个部分转至一个页?
原标题:NextJS - How to pass an event from a component in layout to a page?

在接下来的js中,我有多步骤的形式(再读)。 食堂活动属于布局所呼吁的一个部分,我希望能够添加一个pin子,使提交纽伦。 我怎么能够知道在上页上什么时候有人叫了。

排外。 -

export default function Layout({ children }: { children: React.ReactNode }) {
  return (
    <div>
      <Sidebar />
      <Provider>{children}</Provider>
    </div>
  );
}

供应商。

export default function Provider({ children }: FormProviderProps) {

const onMyFormSubmit = async (data: FormTypes) => {
    await createStory(data);
  }

return (
    <FormProvider {...methods}>
      {/* <form onSubmit={methods.handleSubmit(onSubmit)} className="flex w-full"> */}
      <form onSubmit={methods.handleSubmit((data) => onMyFormSubmit(data))} className="flex w-full">
        {children}
      </form>
    </FormProvider>
  );
}

interface FormProviderProps {
  children: React.ReactNode;
}

页: 1 -

export default function SummaryPage() {
return (
    <div>
    <FormWrapper heading="Finishing up" >
      <div className="flex flex-col bg-alabaster rounded-lg px-4 lg:px-6 mt-6 w-full shrink-0">
        <div className="flex items-center justify-between pt-4 pb-3 lg:pb-5">
        <button
          type="submit"
          disabled={prop I need from onSubmit event}
          className=".."
        >
          Submit story
        </button>
        <div className={prop I need from onSubmit event?  undefined :  hidden }>
          <Spinner height="80" width="80" color="#713F12" />
        </div>
        </div>
      </div>
    </div>
  );  
}

I m new to Next and react, so would really appreciate guidance here. I ve looked at react context, but as far as I understand it, it doesn t seem dynamic (once an object has passed, it doesn t update)

问题回答

您可以通过预支职能作为预支职能,并利用这一职能通知上级部门。

export default function SummaryPage({ disableSubmit, onSubmitCallback }) {
return (
    <div>
    <FormWrapper heading="Finishing up" >
      <div className="flex flex-col bg-alabaster rounded-lg px-4 lg:px-6 mt-6 w-full shrink-0">
        <div className="flex items-center justify-between pt-4 pb-3 lg:pb-5">
        <button
          type="submit"
          onClick={onSubmitCallback} 
          disabled={disableSubmit}
          className=".."
        >
          Submit story
        </button>
        <div className={prop I need from onSubmit event?  undefined :  hidden }>
          <Spinner height="80" width="80" color="#713F12" />
        </div>
        </div>
      </div>
    </div>
  );  
}

然后,你在回复答复之前和之后,就把可拆卸的纽扣地运回国。

否认:

这是一个希望能够回答你问题的好客。 (如上所述,青年可选择将建议适用于将建议直接附加到纽特州的形式)

但是,建议通过使表格组成部分本身处理“合成”要求来简化。

如果多个组成部分需要知道,然后实施全球国家提供者(同形式提供商一样,只是从指数.js/ts中总结所有内容),就可以把“装载”国家视为需要了解的任何组成部分能够直接作出反应。

不要 as击,而要通过每个组成部分 down倒,因为它会很快得到。 只是敌意;如果我不得不通过多个组成部分发出呼吁,就可能重新考虑组成部分的结构。





相关问题
How to use one react app into another react app?

I have two react apps, parent app and child app. and child app have an hash router. I have build the child app using npm run build, It creates build folder. That build folder moved into inside the ...

how to get selected value in Ant Design

I want to print the selected value, and below is my option list: const vesselName = [ { value: 0 , label: ALBIDDA , }, { value: 1 , label: ALRUMEILA , }, { value: 2 ,...

How to add a <br> tag in reactjs between two strings?

I am using react. I want to add a line break <br> between strings No results and Please try another search term. . I have tried No results.<br>Please try another search term. but ...

热门标签