我正在使用react进行一个项目,在其中显示一个列表。列表中的每个条目都由多个输入字段组成,它应该能够只保存一个条目,并且可以一次保存所有条目。
在保存数据时,我希望显示正在保存的元素的加载指示符、一个重试按钮,以防保存失败,并在保存生效时显示一条成功消息。
我认为获得是可能的,但我似乎找不到从使用它的组件外部触发突变的任何方法。
我制作了一个小的代码框来说明设置,否则我的代码会粘贴到下面。
Form.js
import * as React from "react";
import { Person } from "./Person";
export con
在我的多次尝试中,我尝试使用react-apollo-hooks和formik一起使用,但似乎不太可能。表单中的数据仅在<Formik>标记中可用,否则无法在其外部访问。此外,我不能同时调用我的useMutation钩子并将参数传递给它:
const SignUp = () => {
const classes = useStyles();
// The react-apollo-hook for useMutation
// Its not hard to call this, but it seems impossible to call it,
// w
我有一个页面,只要我点击‘提交’按钮,我就更新信息,并且我想更新屏幕的信息,而不必重新加载页面。
这是提交按钮:
import React from 'react';
import { useSaveOrderItemsForList } from '../../hooks/Lists/useSaveOrderItemsForList';
import ErrorIndicator from '../shared/ErrorIndicator';
import LoadingButton from '../shared/LoadingBu
我正在尝试用semantic-ui-react提供的微调器覆盖react-table提供的默认加载器。但这似乎行不通。我维护了三个组件;一个是App,一个用于数据网格,另一个用于微调器。有人能帮帮我吗? 沙盒:https://codesandbox.io/s/react-table-row-table-g3kd5 应用程序组件 import * as React from "react";
import { render } from "react-dom";
import DataGrid from "./DataGrid";
class
我得到一个错误,最终崩溃了一个反应组件的测试。我使用阿波罗钩子突变useMutation和酶的成分发现通过id。
repo code\node_modules\react-dom\cjs\react-dom.development.js:154
var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We
^
TypeError: Cannot read
React查询中的突变最简单的情况是调用突变,然后使查询无效。
ReactQuery将在突变后重新获取背景中的数据,然后重新获取UI将与服务器状态保持一致。
这是使用ReactQuery时突变的“低挂果”:
import { useMutation, useQueryClient } from 'react-query'
const queryClient = useQueryClient()
// When this mutation succeeds, invalidate any queries with the `todos` or `reminders`
我正在编写一个CRUD应用程序,并使用React查询,我创建了一些自定义钩子,如下所述:
在文档中,我看到基本上有两种方法可以在发生突变后更新缓存:
() 查询失效
onSuccess: () => {
queryClient.invalidateQueries("posts");
}
手动更新缓存的()
// Update post example
// I get the updated post data for onSuccess
onSuccess: (data) => {
queryClient.setQueryData("posts