-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditPost.jsx
More file actions
36 lines (31 loc) · 784 Bytes
/
EditPost.jsx
File metadata and controls
36 lines (31 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import React from 'react'
import { useState } from 'react'
import {useParams, useNavigate} from "react-router-dom"
import services from '../appwrite/Services'
import { useEffect } from 'react'
import Container from '../Components/Component/Container'
import { PostForm } from '../Components'
function EditPost() {
const [post, setPost] = useState(null)
const {slug} = useParams()
const navigate = useNavigate()
useEffect(() => {
if (slug) {
services.getPost(slug).then((post) => {
if (post) {
setPost(post)
}else {
navigate("/")
}
})
}
}, [slug, navigate])
return (
<div className='py-6'>
<Container>
<PostForm post={post} />
</Container>
</div>
)
}
export default EditPost