red-gold / react-social-network

Simple React Social Network
https://medium.com/@qolzam/create-social-network-by-react-js-fe60010a32e6
MIT License
490 stars 484 forks source link

Uncaught TypeError: Cannot read property '0' of undefined #111

Closed amorimjr closed 4 years ago

amorimjr commented 5 years ago

When I follow the user I get this error

line 182: "followUser!(followingCircle![0], { avatar, userId, fullName })"

Uncaught TypeError: Cannot read property '0' of undefined  at UserBoxComponent.tsx:182  at Object. (react-dom.production.min.js:14)  at d (react-dom.production.min.js:15)  at react-dom.production.min.js:15  at T (react-dom.production.min.js:17)  at x (react-dom.production.min.js:18)  at C (react-dom.production.min.js:18)  at A (react-dom.production.min.js:21)  at Sn (react-dom.production.min.js:84)  at Au (react-dom.production.min.js:250)

isaacblinder commented 5 years ago

Is there a way I can recreate this error? When I follow a user it appears to work.

kapilip commented 5 years ago

@isaacblinder You can reproduce this issue by creating a fresh database. I encountered this issue with steps mentioned by @amorimjr

ipragmatechadmin commented 5 years ago

@amorimjr @isaacblinder Latest branch(next) works fine now and doesn't have this issue. I tried it yesterday and it was working fine. BTW We are working to support offline for this app and hopefully, you shall access to it in coming days.

heysj commented 5 years ago

I still get this error after getting the latest version. How could I fix this?

Screen Shot 2019-06-05 at 5 48 27 PM
kapilip commented 5 years ago

@heysj Did you use the latest Branch 'Next'? If you follow the instructions for setting up firebase then you shouldn't face any issue.

heysj commented 5 years ago

@kapilip yes, I used the latest Branch 'Next'. There is no error if I use the default firebase configuration in the project, but there is an error when I used my own firebase configuration. Is there something wrong with the firebase cloud functions code that I deployed? I did not set recaptcha.secretKey, phone.sourceNumber, plivo.authId and plivo.authToken in the command line. Thank you very much!

Qolzam commented 5 years ago

@heysj I have just created a new project on Firebase and followed the article. Everything going well. About firebase environment variables. You only need to add gmail and password. By that I have no idea how to reproduce this error.

By the way error says it can not get Following circle. It's a default circle will be initialized in database on user creation in user circle list . Please check when you create your user you have Following circle in database for that user.

firestore-following
heysj commented 5 years ago

@Qolzam thank you very much for your detailed explanation! It seems that in my previous tests, the user document does not have "circles" somehow. I deleted the whole database and signed up new users and now it works. Thank you very much!

ipragmatechadmin commented 5 years ago

@heysj We have written a new blog for the social website so feel free to take a look at https://www.ipragmatech.com/how-effortlessly-create-free-social-media-app-react-nodejs/ and send us your feedback to make it better :)