简体   繁体   English

如何将新行添加到反应表

[英]How to add new row to react-table

I know that this is a very basic question.我知道这是一个非常基本的问题。 But I couldn't find the answer by now.但我现在找不到答案。 In my application, I will fetch some data as an array from my graphql server and directly render it using react-table.在我的应用程序中,我将从我的 graphql 服务器获取一些数据作为数组,并使用 react-table 直接渲染它。 now I want to add a new row to this table.现在我想在这个表中添加一个新行。 How should I do that?我该怎么做? Thank you very much for your help非常感谢您的帮助

  • You should update your data object passed to useTable (refetch data from graphql server, triggering a useEffect which fetches data or...).您应该更新传递给useTabledata object(从graphql服务器重新获取数据,触发获取数据的useEffect或...)。
  • If it is not some data coming from server, you can manually add it to data (append).如果不是来自服务器的某些数据,您可以手动将其添加到data中(追加)。

I think you should always keep the reference to the data object.我认为您应该始终保留对data object 的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM