A library to reduce the need for shouldComponentUpdate boilerplate
npm install re-react#Example
``js
import React, { Component } from "react";
import "re-react";
import { moun } from "enzyme";
class MyComponent extends Component {
static propTypes = {
propA: React.PropTypes.string.affectsRendering
propB: React.PropTypes.string
};
render () {
return (
it("only renders when decorated props change", function () {
const wrapper = mount(
expect(wrapper.find("div").text()).toBe("A: 1, B: 2");
//modifying a prop that hasnt been set to cause re-renders will have no effect
wrapper.setProps({ propB: "3" });
expect(wrapper.find("div").text()).toBe("A: 1, B: 2");
//modifying the prop which affectsRendering, will cause re-render
wrapper.setProps({ propA: "3" });
expect(wrapper.find("div").text()).toBe("A: 3, B: 3");
});
``