如何使 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>;
但是,当我在后端更新数据时,我无法重新获取前端的数据。
这是我能找到的唯一官方文档:https://github.com/sw-yx/fresh-concurrent-react/blob/master/apis/react-cache.md
是否有一些我可以使用的未记录的 API? 🤔
最佳答案
一般来说 - 你不能,这就是它“不稳定”的原因。除了演示和修补之外,请勿将其用于任何其他用途。我们可能会用不同的 API 替换整个内容。
关于reactjs - 在react-cache/suspense中unstable_createResource失效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54558443/