react-cache / suspense中的invalidate_createResource无效

Mic*_*hal 4 invalidation reactjs react-cache

如何使由创建的资源无效react-cache

我可以从API获取数据:

const FooResource = createResource(id => fetch(`/foo/${id}`)); // return a promise, or async/await

// inside render...
const fooResponse = FooResource.read(id); // suspends if not in cache; renders if in cache
return <div> {fooResponse} </div>;
Run Code Online (Sandbox Code Playgroud)

但是,当我在后端更新数据时,我无法重新获取前端的数据。

这是我唯一能找到的官方文档:https : //github.com/sw-yx/fresh-concurrent-react/blob/master/apis/react-cache.md

我可以使用一些未公开的API吗?

Dan*_*mov 5

通常,您不能,这就是为什么它“不稳定”的原因。除了演示和修补之外,请勿将其用于其他任何用途。我们可能会用不同的API替换整个内容。