Skip to content

Latest commit

 

History

History
28 lines (16 loc) · 581 Bytes

state.md

File metadata and controls

28 lines (16 loc) · 581 Bytes

.state([key]) => Any

Returns the state hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value.

Arguments

  1. key (String [optional]): If provided, the return value will be the this.state[key] of the root component instance.

Example

const wrapper = shallow(<MyComponent />);
expect(wrapper.state().foo).to.equal(10);
expect(wrapper.state('foo')).to.equal(10);

Related Methods