Back to Blog
My First Blog

My First Blog

2 min read
Navneet Srivastava
React

Introduction

A few months ago, photos of Hamas terrorists were paraded on elephants during the Thrithala Fest in Kerala. That was considered okay. But, when Onam flower designs depicted Operation Sindoor as a tribute to Indian Forces in front of a temple in Kerala, the police objected. That was not okay. Terrorists get respect, patriots get restrictions. Appeasement decides what is "allowed" and what is "objected to".

"use client"

import React, { useState, useEffect, use } from "react"

import { useRouter } from "next/navigation"

export default function EditBlogPost({ params }: { params: Promise<{ slug: string }> }) {

const { slug } = use(params) // ✅ unwrap the promise here

const [post, setPost] = useState<BlogPost | null>(null)

const [isLoading, setIsLoading] = useState(false)

const [content, setContent] = useState("")

const [formData, setFormData] = useState({

title: "",

description: "",

category: "",

image: "",

})

const router = useRouter()

useEffect(() => {

const fetchPost = async () => {

const post = await getPostBySlug(slug) // use unwrapped slug

setPost(post)

setFormData({

title: post.title,

description: post.description,

category: post.category,

image: post.image,

})

setContent(post.content)

}

fetchPost()

}, [slug, router])

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {

const { name, value } = e.target

setFormData((prev) => ({ ...prev, [name]: value }))

}

return (

<div>

{/* your form UI */}

</div>

)

}