正如您所提到的,解决它的独特方法是批量处理所有突变,请查看相关问题!
实际上,编写它们并没有那么糟糕,您可以执行以下操作:
const handleClick = async (mutation1Fn, mutation2Fn, mutation3Fn) => {
const data1 = await mutation1Fn()
const data2 = await mutation2Fn()
const data3 = await mutation3Fn()
}
const Mutations = () => (
<Composer
components={[
<Mutation mutation={mutation1} />,
<Mutation mutation={mutation2} />,
<Mutation mutation={mutation3} />
]}
>
{([mutation1Fn, mutation2Fn, mutation3Fn]) => (
<button
onClick={() => handleClick(mutation1Fn, mutation2Fn, mutation3Fn)}
>
exec!
</button>
)}
</Composer>
)
如果你有什么困难,请告诉我!