Answer the question
In order to leave comments, you need to log in
How to pass two functions one by one to onClick()?
<PanelHeaderButton onClick={this.props.go} data-to='Home'><Icon28ChevronLeftOutline/></PanelHeaderButton>
const [activePanel, setActivePanel] = useState('Home');
const go = e => {
setActivePanel(e.currentTarget.dataset.to);
};
Answer the question
In order to leave comments, you need to log in
Usually, an event handler is defined, and the necessary functions are called in it
const handleClick = useCallback((ev) => { // меморизирую, т.к. обработчик передается в компонент а не HTML элемент
props.go(ev); // более правильно конечно передавать не объект события, а конкретное значение. Функция go не должна ничего знать про событие
// тут вызов второй функции
}, []);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question