Download dev.to-clone/src/pages/CreatePost.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/dev.to-clone/src/pages/CreatePost.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/dev.to-clone/src/pages/CreatePost.jsx
-
curl -L -o CreatePost.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/dev.to-clone/src/pages/CreatePost.jsx
1.23 kB
| import React, { useEffect } from "react"; | |
| import { Navigate } from "react-router-dom"; | |
| import CreatePostForm from "../components/post/CreatePostForm"; | |
| import { useAuth } from "../context/auth"; | |
| import useCreatePost from "../hooks/useCreatePost"; | |
| const CreatePost = ({ currentPostDataToEdit }) => { | |
| //scroll top | |
| useEffect(() => window.scrollTo(0, 0), []); | |
| const user = useAuth(); | |
| const { | |
| postData, | |
| title, | |
| setTitle, | |
| publishing, | |
| savingDraft, | |
| uploadingImg, | |
| setUploadingImg, | |
| publishPostHandler, | |
| draftPostHandler, | |
| eidtPostHandler, | |
| } = useCreatePost(currentPostDataToEdit); | |
| if (!user) { | |
| return <Navigate to="/create-account" replace />; | |
| } | |
| return ( | |
| <CreatePostForm | |
| publishPostHandler={publishPostHandler} | |
| draftPostHandler={draftPostHandler} | |
| eidtPostHandler={eidtPostHandler} | |
| setPostTitle={setTitle} | |
| postTitle={title} | |
| postData={postData} | |
| pageTitle={currentPostDataToEdit ? "Edit" : "Create"} | |
| publishing={publishing} | |
| savingDraft={savingDraft} | |
| uploadingImg={uploadingImg} | |
| setUploadingImg={setUploadingImg} | |
| toEdit={currentPostDataToEdit ? true : false} | |
| /> | |
| ); | |
| }; | |
| export default CreatePost; | |