Spec-Zone.ru › Enzyme

.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 = mount(<MyComponent />);
expect(wrapper.state().foo).to.equal(10);
expect(wrapper.state('foo')).to.equal(10);

Related Methods

  • .props() => Object
  • .prop(key) => Any
  • .context([key]) => Any

© 2015 Airbnb, Inc.
Licensed under the MIT License.
https://enzymejs.github.io/enzyme/docs/api/ReactWrapper/state.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API