samedi 23 novembre 2019

Test event bubbling in React

Is it possible to test event bubbling in React?

For example:

Class Foo extends React.Component {
    doSmth() {
        console.log('bubble');
    }

    render() {
        return (
            <div onClick={this.doSmth}>
                <Bar />
            </div>
        );
    }
}

I have a parent and a child components. Click event is fired somewhere in a Bar component.
How to test that doSmth was executed in a Foo component?
Also i have to mention that i can't use context and props, cause this is a very simplified version.

Aucun commentaire:

Enregistrer un commentaire