Nextjs state not updating on route change – Reactjs
I know there's a lot of questions in the same topic. I've been reading for about 2 days about this and i cant make it work. So my situation is this: I have several dynamic routes in my Nextjs app…
I know there's a lot of questions in the same topic. I've been reading for about 2 days about this and i cant make it work. So my situation is this: I have several dynamic routes in my Nextjs app…
I need to use localStorage in nextjs but after refresh i lose all the data (empty array [] in the console). this is what i tried: const [todos, setTodos] = useState([]); useEffect(() => { const storedTodos = JSON.parse(localStorage.getItem('todos')) || [];…
im trying to update data in mern stack application and i found that the formdata is empty and i wonder why ! i get all the value and pased them in function update to update the data and then i…
Creating a component to wrap every page with the hope of receiving children and title for each page is throwing error. "Title element received an array with more than 1 element as children." import Head from "next/head"; interface IProps {…
I am using next.js. I have json file with a string: { "title":"Just a text with <b>accent</b> inside", } I want get this string and return a string with <b> tag inside. There is my function: function parseTitle(title) { let…
I am working on a Next.js project with authentication and am putting some URLs as strings into an array called protectedRoutes, so people get redirected when they access those URLs before they sign in. const protectedRoutes = ["/home", "/profile", etc.];…
When I run npx create-next-app, I get this question What import alias would you like configured? ... ** / * ) I want to be able to use normal ES6 import statements for example. import Nav from "../components/Nav" Instead of…
I was using Myjson.slice(1, 20). I need only 20 items from Myjson which has a length of 2624 and in this code I tried to you slice like this but I don't know what to do to make the difference…
In Next.js I'm using this code: const [card, setcard] = useState([]); useEffect(() => { localStorage.setItem('items', JSON.stringify(card)); }, [card]); useEffect(() => { const items = JSON.parse(localStorage.getItem('items')); if (items) { setcard(items); } }, []); I can see that when the value of…
I have a simple project built in: Node v16.14 Express Nextjs v13.2 I want to serve the output generated from Nextjs Static HTML Export in NestJS with Serve Static or in Express. The output from my Nextjs build doesn't include…