V
V
Vladimir Golub2019-03-28 18:05:09
JavaScript
Vladimir Golub, 2019-03-28 18:05:09

Why is the event not passed when calling two functions via onClick?

When calling two functions via onClick error: "Cannot read property 'preventDefault' of undefined"

onClick={(e) => {onClickFunc(idx, e); handlerChangeTab(idx);}}

onToggleTab = (val, e) => {
        e.preventDefault();

        this.setState(() => {
            return {
                activeTab: val
            }
        })
    };

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Doctor Bi, 2019-03-28
@scanerrr

Do it through the handler

handleClick(e, idx) {
   onClickFunc(idx, e);
   handlerChangeTab(idx);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question