Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canot read properties of undefind (reading 'replace') #18

Open
jirawatfreedom opened this issue Jan 11, 2022 · 5 comments
Open

Canot read properties of undefind (reading 'replace') #18

jirawatfreedom opened this issue Jan 11, 2022 · 5 comments

Comments

@jirawatfreedom
Copy link

jirawatfreedom commented Jan 11, 2022

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 (

@fjerbi
Copy link

fjerbi commented Jan 16, 2022

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.

@lukeryandev
Copy link

image

Same issue here, props passed in.

@lukeryandev
Copy link

lukeryandev commented Jan 18, 2023

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");

image

@jasdeepdhillon13
Copy link

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.

@Abdullah-encrypts
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants