I'm following a course and I have this issue where I can't reference/access object instances passed as a prop. For example, lets call this component CalenderDate.js and inside I have the following code:
function CalenderDate(props) {
return (
<div className="date">
<div>
<div>{props.date.toLocaleString('en-US', { month: 'long' })}</div>
<div>Date</div>
<div>Year</div>
</div>
</div>
)
}
And then in App.js I do this:
function App() {
const array = [
{
date: new Date(2020, 11, 23),
words:"string of text"},
{
winningNumber: 7,
message: "Winning Number 7"}
]
return(
<>
<CalenderDate date = array[0].date></CalenderDate>
</>
)
}
Somehow, in CalenderDate.js prop.date becomes undefined and now, on my react page the console shows an error,
Cannot read properties of undefined (reading 'toLocaleString')
Help, please!