Render Conditionally from Props -- Test errors

Tell us what’s happening:

I think something is wrong with the tests. I am meeting all of the criteria for the tests, but still failing two with the console showing an error message:

Method “text” is only meant to be run on a single node. 2 found instead.

Timeout has occurred

Your code so far


class Results extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
     console.log(this.props.fiftyFifty)
    return (
      <h1>
      {this.props.fiftyFifty ? (<p>"You Win!"</p>) : (<p>"You Lose!"</p>) }
      </h1>
    )
  };
};

class GameOfChance extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 1
    }
    this.handleClick = this.handleClick.bind(this);
  }
  handleClick() {
    this.setState({
      counter: this.state.counter + 1 
    });
  }
  render() {
    let expression = Math.random() > .5;
    return (
      <div>
        <button onClick={this.handleClick}>Play Again</button>
        <Results fiftyFifty={expression} />
        <p>{'Turn: ' + this.state.counter}</p>
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:

Try just returning the strings “You Win!” or “You Lose!” and not the p elements.

1 Like