使用ControlShouldRendervalue设置为TRUE不工作的多选择

发布于 2025-01-30 09:08:39 字数 277 浏览 3 评论 0 原文

我有一个表格的表包含一排选择。我正在尝试显示各自选择下的选择,但是选择仅在其中一个选择下显示。我不确定这里怎么了。

我在这里有一个工作示例:

在我的代码中,当我更改任何一个选择时,选择在第一个选择下方。谁能解释一下?

I have a table who's header contains a row of selects. I am trying to display the selections under their respective selects however the selections only show under one of the selects. Im not sure whats going wrong here.

I have a working example here: https://codesandbox.io/s/table-with-multiselcts-fwhsus?file=/src/App.js

In my code the selections are updating underneath the first select when I change any one of the selects. Can anyone explain this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨小墨 2025-02-06 09:08:39

您使用了相同的Onchange回调。
问题在于此功能的参数。
字段不是字符串,它是对象。
因此,在Switch语句中,仅执行默认情况。
最好分别设置Onchange回调。

onChange={e => setLocation(e.target.value)}
onChange={e => setPractice(e.target.value)}
...

You used the same onChange callback.
The problem is in the parameters of this function.
field is not a string, it's an object.
So in the switch statement, only default case is executed.
It would be better to set onChange callback respectively.

onChange={e => setLocation(e.target.value)}
onChange={e => setPractice(e.target.value)}
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文