What's the benefit or the logic?

Tell us what’s happening:

Hello,
can anyone please clarify why my code is not acceptable outside the boundaries of the challenge itself?
If I had to render a component called CurrentDate holding the current date, I would like to give that property to the component and let the Parent only the display action. What’s the benefit or the logic of passing the variable to the Calendar component since the result is the same?
Thanks

Your code so far


const CurrentDate = (props) => {
return (
  <div>
    { /* change code below this line */ }
    <p>The current date is: {Date()}</p>
    { /* change code above this line */ }
  </div>
);
};

class Calendar extends React.Component {
constructor(props) {
  super(props);
}
render() {
  return (
    <div>
      <h3>What date is it?</h3>
      { /* change code below this line */ }
      <CurrentDate />
      { /* change code above this line */ }
    </div>
  );
}
};

Your browser information:

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

Challenge: Pass Props to a Stateless Functional Component

Link to the challenge:

Hello @lorenzo0572, React has a data flows down model, this means that if two component will need to access the same data, it needs to be stored to the closest ancestor they have in common.

So for a simple case like this one, there’s no real difference.
But if later you’ll find yourself in the position of another component needing the Date, you’ll need it to be stored in the parent component.

So treat this mainly as an exercise :slight_smile: