我在ThemeModal组件中没有获取到sectionId的数据

问题描述 投票:0回答:0

我目前正在开发 Shopify remix 应用程序。我制作了一条路线 app.sections。我编写一个查询来从加载器函数中的数据库获取数据,并将其导出到我的组件中,现在在我的组件中,我通过 props 将此数据传递到另一个名为 ProductCard 的组件,并再次将此数据从 ProductCard 传递到 ThemeModel 组件。在我的产品卡组件中,有一个名为“安装”部分的按钮,单击该按钮时我会显示 ThemeModel 组件。 ThemeModal 是一个单一模态,显示 Shopify 在线商店的主题列表。 themeModal 末尾有一个提交按钮,我在其中使用 Remix 的 Form API 并给出应用程序/部分路径的操作路径。因此,当我单击按钮时,此功能有效,但每次我获得部分 id 1 时。那么,当我单击不同部分时,如何获得不同的部分 id?

1 - 映射到totalSection 并提供给ProductCard 组件 2 - 将 ProductCard 中的totalTheme 和section_id 提供给ThemeModal 组件 3 - 使用 ThemeModal 组件并在“提交”按钮处提供“section_id”和“selectedThemeId”。

<Form
  method="post"
  action={`/app/section/${postId}`}
>
  <input type="hidden" value=(active_section_id) name="section_id" />
  <input type="hidden" value={selectedOption} name="selectedThemeId" />
  <button
    name="_action"
    type="submit"
    value="create"
    onClick={() => shopify-modal.hide("my-modal")}
  >Submit</button>
</Form>
[1 image]:(https://i.stack.imgur.com/GPKHu.png)
[2 image]:(https://i.stack.imgur.com/iT4OB.png)
[3 image]:(https://i.stack.imgur.com/BtU6z.png)

所以,我希望当单击 ThemeModal 的提交按钮时,我不会得到不同的部分 ID。 我每次都只得到section-id = 1.

javascript reactjs react-hooks shopify-app remix.run
© www.soinside.com 2019 - 2024. All rights reserved.