React - Pass Props to a Stateless Functional Component

Tell us what’s happening:

I tried to run the Test when it’s said not correct altough i use the same code on the solution from hint, it seems like a bug or something i tried to run it after few days and still got the error code on log

  • Failed:1. The Calendar component should return a single div element.

  • Failed:2. The second child of the Calendar component should be the CurrentDate component.

  • Failed:3. The CurrentDate component should have a prop called date.

  • Failed:4. The date prop of the CurrentDate should contain a string of text.

  • Passed:5. The date prop should be generated by calling Date()

  • Passed:6. The CurrentDate component should render the value from the date prop in the p tag.

but when i change the code on

<CurrentDate date={Date ()}  />

to

<CurrentDate date='the date'  />

the test came back like this

    1. The Calendar component should return a single div element.
  • Passed:2. The second child of the Calendar component should be the CurrentDate component.

  • Passed:3. The CurrentDate component should have a prop called date.

  • Passed:4. The date prop of the CurrentDate should contain a string of text.

  • Failed:5. The date prop should be generated by calling Date()

  • Passed:6. The CurrentDate component should render the value from the date prop in the p tag.

Your code so far

const CurrentDate = (props) => {
  return (
    <div>
      { /* Change code below this line */ }
      <p>The current date is: {props.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 date={Date ()}  />
        { /* Change code above this line */ }
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36

Challenge Information:

React - Pass Props to a Stateless Functional Component

Hi there and welcome to our community!

You shouldn’t have a space before the parentheses here.

hi, thanks for noticing that. i change the code to

<CurrentDate date={Date()}  />

but the test result like this

    1. The Calendar component should return a single div element.
  • Failed:2. The second child of the Calendar component should be the CurrentDate component.

  • Failed:3. The CurrentDate component should have a prop called date.

  • Failed:4. The date prop of the CurrentDate should contain a string of text.

  • Passed:5. The date prop should be generated by calling Date()

  • Passed:6. The CurrentDate component should render the value from the date prop in the p tag.

With that one change I highlighted, your code passes for me.
You may need to hit the Reset button and then resubmit your code, to pass this step.

I’ve done reset and resubmit my code but still got the same result. Does this have any influence on the browser/OS that I use?

It’s possible that browser extensions could interfere with the tests. Try disabling all extensions.
You could also try a hard refresh (CTRL + F5), private/incognito mode or a different browser.

Hope that helps!