Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ComponentToBeTested extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- isActive: false
- };
- this.handleButtonClick = this.handleButtonClick.bind(this);
- }
- handleButtonClick() {
- this.setState({
- isActive: !this.state.isActive
- });
- }
- multiply(data) {
- return data * 10;
- }
- square(data) {
- return Math.pow(data, 2);
- }
- render() {
- const givenData = this.props.data;
- const multipliedData = this.multiply(givenData);
- const squaredData = this.square(givenData);
- return (
- <div className="ComponentToBeTested">
- <button className="test-button" onClick={this.handleButtonClick}>
- FOO
- </button>
- <ChildComponent data={multipliedData} />
- <span className="squared-data">{squaredData}</span>
- </div>
- );
- }
Add Comment
Please, Sign In to add comment