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/reduceRight.html below:

reduceRight(fn[, initialValue]) ยท Enzyme

.reduceRight(fn[, initialValue]) => Any

Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node is passed in as a ShallowWrapper, and is processed from right to left.

Arguments
  1. fn (Function): A reducing function to be run for every node in the collection, with the following arguments:

  2. initialValue (T [optional]): If provided, this will be passed in as the first argument to the first invocation of the reducing function. If omitted, the first node will be provided and the iteration will begin on the second node in the collection.

Returns

T: Returns an array of the returned values from the mapping function...

Example
function Foo() {
  return (
    <div>
      <Bar amount={2} />
      <Bar amount={4} />
      <Bar amount={8} />
    </div>
  );
}
const wrapper = shallow(<Foo />);
const total = wrapper.find(Bar).reduceRight((amount, n) => amount + n.prop('amount'), 0);
expect(total).to.equal(14);

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