Problems with Render Conditionally from Props

Problems with Render Conditionally from Props
0

#1

Tell us what’s happening:

Hello friends the the code it is making everything good but there is a detail.
I dont understand this aspect:

“GameOfChance should return a single instance of the Results component, which has a prop called fiftyFifty.”

What it means that.

Thank you

Your code so far


class Results extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <h1>
      {
      this.props.fifyFifty === true ?
      "You win!" :
      "You lose!"
      }
      </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() > 0.5; // change code here
    return (
      <div>
        <button onClick={this.handleClick}>Play Again</button>
        { /* change code below this line */ }
        <Results fifyFifty = {expression}/>
        { /* change code above this line */ }
        <p>{'Turn: ' + this.state.counter}</p>
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/render-conditionally-from-props


#2

@rubendmatos1985 Your code looks right to me. I wonder if this is a syntax problem? You have:

<Results fifyFifty = {expression}/>

Maybe try it without the spaces between fiftyFity and the =?

<Results fifyFifty={expression}/>

#3

Although your code “works”, it is failing the tests because of the same typo in to parts of your code.
Inside the Results component’s render:

this.props.fifyFifty

Inside the GameOfChance components’ render:

<Results fifyFifty = {expression}/>

Carefully review the challenge instructions regarding the spelling of the prop name and you should be able to see your mistake.