In the getStaticPaths function, there is a path returned with params postId:1. If have two or three more params with postId: 2, postId: 3 etc. those will be statically generated. Right? Is there a way not to statically load any post with any id? If I want to load all the posts with the loading screen, is that can be
Tag: next.js
Can’t get single item to delete by id from mongoDB in nextjs app
I’m making a todo app in nextjs to practice, and I am having a hard time getting single todos to delete from the database using the deleteOne function. Here is the call from the front end: and here is the handling of the DELETE method: and the deleteTodo helper function it calls: I can get it to delete the first
redux is not re-rendering component with React 18
I have a custom hook which handles global data fetching based on user authentication. the hook is like this: but since I am using React 18 strict mode (in NextJS), the useEffect only runs twice with userState === “loading” value and won’t run when state updates. I’m not sure if I should give more details of my code. If you
How can I add animation to react state
I just want to add a fade in animation to next index. i found a package called “react transition group” but all tutorials were based on class components or redux I didn’t understand anything. Answer SwitchTransition waits for the old child to exit then render the new child as mentioned in the react transition group website. there are two modes:
.map() through array of object in next.js does not display in html but in console?
I am not able to display the elements of this array in html. I am fetching data from the Bscscan api. I can fetch perfectly from the first api but the second does not show the data in the local browser. I will show you all the code I’ve got. I added also pictures of what the browser looks like
Nextjs: set priority for useEffect
This is my _app.tsx And this is my index.tsx So, in my console print 21 But I want to print 12 How can I set priority for useEffect for run _app first? Answer Short Answer You can’t set priority across components. Long Answer Disregarding why someone would need control over the priority of useEffect across components in the first place,
Pass multiple values to a param in getStaticPaths() in nextjs
I want to have two routes /midterm/cs611 /finalterm/cs611 All i am trying to do is when i hit endpoint /midterm/cs611 it should display different content and when it hits to /finalterm/cs611 it should display different content. But i end up with correct results when hitting /finalterm/cs611 and when i hit /midterm/cs611 it shows 404 page. If i replace like ‘midterm’
Why is getServerSideProps data being changed?
I’ll fetch data from an API, When I pass my getServerSideProps data to index.js, the prop array is in order by rank. [1,2,3..etc]. ex: data When I alter that data into a different variable, for example: console log shows data is now sorted by price too, when I only wanted topPrice to be sorted, why? Answer sort function alters your
Increment and decrement counter according to select or unselect tag
I am working with the next js to handle a question form, I have multiple questions that have multiple answers, and the user may select one or multiple tags for a question. if a user selects one or more tag to answer a question it must increment the counter just one time, If a user unselect a tag it must
NextJS render content from a different page
I’ve two routes like, app/products => pages/products/index.js app/products/1 => pages/products/[page].js Here both app/products and app/product/1 will render the same content (same product items), is it possible to render app/products/1 content in app/products without writing duplicate code? I could find anything similar in their documentation. Thanks. Answer The easiest way is to abstract the content from the page level. No need