使用 useShallow 防止重新渲染
例子
import { create } from "zustand";
const useMeals = create(() => ({
papaBear: "large porridge-pot",
mamaBear: "middle-size porridge pot",
littleBear: "A little, small, wee pot",
}));
export const BearNames = () => {
const names = useMeals((state) => Object.keys(state));
return <div>{names.join(", ")}</div>;
};最后更新于