3
votes

I am facing an error in EventLink. Pretty sure there shouldn't be any issues. Am I not calling the props correctly?

Error:

TypeError: Cannot read property 'title' of undefined

Code:

function EventItem({ props }) {
  return (
    <div className="event">
      <div className="top-info">
        <CompactDateField props={props} />
      </div>
      <h2 className="title no-marg-top">
        <EventLink
          title={props.title}
          eventId={props.event_id}
          slug={`/${props.slug}`}
          dateId={props.id}
        />
      </h2>
...
2

2 Answers

4
votes

Props is an object - there's no need to destructure it. Simply remove the curly brackets from arguments.

function EventItem(props) {
1
votes

Otherwise, you can use spread operator

function EventItem({ ...props }) {
}