有没有办法在 remix 中使用 useLoaderData 重新获取?
Is there a way to refetch with useLoaderData in remix?
我正在学习混音,我的加载器中有一些函数,我在默认路由中使用 useLoaderData 调用这些函数,如下所示:
export const loader = async () => {
const pokemon = await getRandomPokemon();
const types = await getAllPokemonTypes();
return [pokemon, types.results];
};
export default function App() {
const [pokemon, types] = useLoaderData();
...
}
我想添加一个按钮来重新加载数据(因为在这种情况下我想要一个新的随机口袋妖怪)
使用混音 Form
(或 HTML 形式):
<Form method="get">
<button type="submit">Reload</button>
</Form>
提交此表单将执行 loader
功能。
我正在学习混音,我的加载器中有一些函数,我在默认路由中使用 useLoaderData 调用这些函数,如下所示:
export const loader = async () => {
const pokemon = await getRandomPokemon();
const types = await getAllPokemonTypes();
return [pokemon, types.results];
};
export default function App() {
const [pokemon, types] = useLoaderData();
...
}
我想添加一个按钮来重新加载数据(因为在这种情况下我想要一个新的随机口袋妖怪)
使用混音 Form
(或 HTML 形式):
<Form method="get">
<button type="submit">Reload</button>
</Form>
提交此表单将执行 loader
功能。