const App = () => {
function hideCharacter(){
const randomChar = useRef(null);
randomChar.classList.add('hide');
}
return (
<>
<RandomChar ref={randomChar} /> // error: not defined
<button class="btn btn-primary" onClick={hideCharacter()}>Load another one</button>
</>
);
};
为什么我的引用没有定义?我需要将代码重构为类吗?
摇曳的蔷薇
相关分类