nextjs-course-code
nextjs-course-code copied to clipboard
Canot read properties of undefind (reading 'replace')
error - components\events\event-item.js (17:36) @ EventItem TypeError: Cannot read properties of undefined (reading 'replace') 15 | year: 'numeric', 16 | });
17 | const formattedAddress = location.replace(', ', '\n');
| ^ 18 | const exploreLink =/events/${id}
; 19 | 20 | return (
That Error message means that he couldn't access the location prop.
Are you passing location
as a prop?
you should have this :
const { title, image, date, location, id } = props;
In the beginning of your component.
and do not forget to pass props
in your component.

Same issue here, props passed in.
I also added an optional chain, this is what displays when the formatting is skipped: EDIT: Same result when String(location) is applied.
const formattedAddress = location?.replace(", ", "\n");

In some cases, this issue can be caused by not changing the firebase url in the api-utils.js file, which is set to point to the firebase by max. You should either replace the firebase url in the response variable to your own firebase url.
In some cases, this issue can be caused by not changing the firebase url in the api-utils.js file, which is set to point to the firebase by max. You should either replace the firebase url in the response variable to your own firebase url.
Yup when i was in that module i had the same issue and it was being caused by the firebase url