最佳答案
我有一个使用 useContext
的组件,它的输出取决于上下文中的值。举个简单的例子:
import React, { useContext } from 'react';
const MyComponent = () => {
const name = useContext(NameContext);
return <div>{name}</div>;
};
在使用 response 和 jest 快照的浅显呈现程序测试此组件时。如何更改 NameContext
的值?