我在 Component.js 中有一个组件,其中横幅是另一个组件。我怎样才能测试不同的计数?我尝试使用react-testing-library 对其进行测试,但子组件没有更新。Useeffect也不适用于酶
const [newCount, setCounter] = useState(0);
useEffect(() => {
const counter = getCounterValue('counter1');
setCounter(counter);
});
labels = {title : 'hello', description: 'there', title_v1 : 'Hi',description_v1: 'World' };
switch (newCount) {
case 1:
labels.description = labels.description_v1;
labels.title = labels.title_v1;
break;
case 2:
labels.description = '';
labels.title = labels.title_v1;
break;
default:
break;
}
return (<Banner {...labels}/>);