A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://enzymejs.github.io/enzyme/docs/api/ShallowWrapper/invoke.html below:

invoke(propName) ยท Enzyme

.invoke(invokePropName)(...args) => Any

Invokes a function prop.

Arguments
  1. propName (String): The function prop that is invoked
  2. ...args (Any [optional]): Arguments that is passed to the prop function

This essentially calls wrapper.prop(propName)(...args).

Returns

Any: Returns the value from the prop function

Example
class Foo extends React.Component {
  loadData() {
    return fetch();
  }

  render() {
    return (
      <div>
        <button
          type="button"
          onClick={() => this.loadData()}
        >
          Load more
        </button>
      </div>
    );
  }
}
const wrapper = shallow(<Foo />);
wrapper.find('button').invoke('onClick')().then(() => {
  // expect()
});

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4