fireship-io / fireship.io

Build and ship your app faster https://fireship.io
3.54k stars 1.31k forks source link

courses/react-next-firebase/admin-forms/ #875

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Post Editing Form

Use react-hook-forms to create a form to edit posts in markdown

https://fireship.io/courses/react-next-firebase/ssr-profile-page/

marcelofrayha commented 2 years ago

can't make this page work. All I get is an empty page with no error thrown

bbissm commented 2 years ago

I currently face the same issue. When doing const [post] = useDocumentData(postRef); post returns undefined.

bbissm commented 2 years ago

I Solved it. Check in firebase if the id of your post is same as the slug. It should be for example hello-world instead of hJyyEuKAVlg9TFVIVlGx

JimboTron9000 commented 2 years ago

If any of you are getting the error " Type Error: path.split is not a function ". Then you must change the useForm register hook to the new updated verson. {...register("NAMEHERE")} instead of ref={register} <textarea {...register("content")}>

Casal0x commented 1 year ago

@marcelofrayha how you fixed it because i'm having the same issue

toppyc4 commented 1 year ago

@bbissm can you explain a bit more I am facing the same issue and seem like I got my post id same as slug already but post still return 'undefined'

toppyc4 commented 1 year ago

I am currently facing the same issue. The problem is useDocumentDataOnce function make the 'post' variable return 'undefined' Right now I still can't find the solution, but the quick-fix, as mention in https://github.com/CSFrequency/react-firebase-hooks/issues/252, is to use useDocumentData instead. Hope it help.