如何使React Admin' S< SimpleFormiterator>作为添加物品的堆栈表现(在顶部添加项目)?
我有一个带有项目嵌套列表的项目。我可以使用< siplyformiterator> 与A < formDataConsumer> 分别编辑这些嵌套项目。问题是,当我将新项目插入列表中时,它将成为最后一项。我希望它是第一个,然后将其他所有项目转移到一个插槽中。
也许像 addontop 回调一样使用自定义 可能会有所帮助?但是我看不到可以使其正常工作的方法,而不会从头开始重写整个组件。
<SimpleFormIterator
addButton={<ListAddButton onClick={addOnTop??} />}
removeButton={<ListRemoveButton />}
>
...
</SimpleFormIterator>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许尝试使用unshift()。这是链接:
Maybe try with unshift(). Here is the link:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift
最后,我认为我设法解决了这样的事情:
我不确定这是最好的方法,但是它似乎有效,尽管目前有一个与此组件的错误 迫使使用“ emptyArticle” ,而不是简单地推动 “ undefined” < /em>。
In the end I think I managed to solve doing something like this:
I'm not sure it is the best approach, but it seems to work, although there is currently a bug with this component that forces the use of "emptyArticle" instead of simply pushing "undefined".