Date Prop is not generated by Date()

Tell us what’s happening:
Describe your issue in detail here.

Hello, I’ve struggled a lot with this problem and found a solution but the condition - " The date prop should be generated by calling Date()".

The console says ’ The date prop should be generated by calling Date() (Test timed out)’. I’ve checked the solution and I’ve done everything exactly as it’s written there but the solution itself does not work too if I copypaste it in the code editor.

I’d love to receive your help, Thank you in advance.

  **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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36

Challenge: Pass Props to a Stateless Functional Component

Link to the challenge:

const a = Date();
const b = new Date();

console.log(a);
console.log(typeof a);

console.log(b);
console.log(typeof b);

You’re giving it a string as the prop. The MDN Date documentation is your friend here.

Also, it’s easier to debug if you include a link to a repl and/or the challenge.

1 Like

okay, the challenge link is:

Tbh, I did not get the answer :sweat_smile: You said that I am giving a string as a prop. I should not be doing that? What type should I give as the prop then?

the task itself says that the date prop should contain a string of text.

Both your code and the solution code work for me. Try resetting the challenge and do a hard refresh (Shift + F5) now paste in the code again and see if it works.

strange. I tried both and both are not working. I’ll try to write to the FreeCodeCamp team itself to consider my problem or refresh the solution. The solution was posted on 13th august 2019.

There is no problem with the solution code. Try in a Private window without extensions or in a different browser.

I tried and it worked. Thank you very much.