如果我计算了一个对象的哈希值(据我所知,该哈希值可以准确表示该对象中的信息),是否可以安全地将该哈希值作为依赖项传递到useEffect
挂钩中?
interface FooBar {
readonly __hash: string;
readonly foo: string;
readonly bar: string;
}
const createFooBar = (foo: string, bar: string) => {
return {
__hash: `${foo}_${bar}`,
foo,
bar
};
};
const MyComponent: FunctionComponent<{readonly fooBar: FooBar;}> = ({fooBar}) => {
useEffect(() => {
//use fooBar.foo and fooBar.bar here
}, [fooBar.__hash]);
return <>{/*UI THINGS HERE*/}</>
};