next.js

is there a way to keep router query on page refresh in nextjs

二次信任 提交于 2020-12-15 06:42:12
问题 I have a dynamic page with a dynamic url. everything is clientside rendered. This is the link that links to the second page <Link href= {{ pathname: '/dashboard/[orderdetail]', query: { id: `${orderID}` } }} as={`/dashboard/${orderDetails.orderNo}`} </Link> This works well taking every query to the second page. But when I refresh the second page, everything is lost. Every query i had passed is lost I have tried using with/Router let orderID=this.props.router.query.orderdetail; Still on page

redux persist in the next js project persist:root is not creating localstorage

…衆ロ難τιáo~ 提交于 2020-12-15 06:27:49
问题 using the nextjs framework the redux-persist is not creating the local storage values. After login the persist:root is not showing in the local In the reactjs framework, I have tried the redux persist the persist:root created in the local storage but in the nextjs framework the same method I am following the errors not coming but the persist:root is not showing in the local storage //store.js import { createStore, applyMiddleware, compose } from 'redux'; import thunk from 'redux-thunk';

Next.js - How to add a <link> tag inside the <head> with literal onload attribute string value?

这一生的挚爱 提交于 2020-12-15 06:23:08
问题 On a Next.js project, I'd like to get some initial HTML with this exact same content inside the <head> : <link href="..." rel="stylesheet" media="print" onload="this.media='all'" /> What I have in my code, inside Next.js's <Head> component, is: { /* @ts-ignore */ } <link href="..." rel="stylesheet" media="print" onload="this.media='all'" /> Without the @ts-ignore it says: Property 'onload' does not exist on type 'DetailedHTMLProps<LinkHTMLAttributes, HTMLLinkElement>'. Did you mean 'onLoad'?

NextJS - Appending a query param to a dynamic route

我只是一个虾纸丫 提交于 2020-12-13 07:59:51
问题 In my NextJS app, I have a language selector that's visible on every page. When I select a new language, I just want to replace the current URL by appending a query param lang=en to it. Here's the function that replaces the URL: const changeLanguage = (lang: LanguageID) => { replace({ pathname, query: { ...query, lang }, }); }; In this example, replace , query and pathname are coming from the next router. Now, everything works for static routes, but I'm unable to make it work for dynamic

NextJS - Appending a query param to a dynamic route

99封情书 提交于 2020-12-13 07:58:13
问题 In my NextJS app, I have a language selector that's visible on every page. When I select a new language, I just want to replace the current URL by appending a query param lang=en to it. Here's the function that replaces the URL: const changeLanguage = (lang: LanguageID) => { replace({ pathname, query: { ...query, lang }, }); }; In this example, replace , query and pathname are coming from the next router. Now, everything works for static routes, but I'm unable to make it work for dynamic

How can I specify the optional parameters in the dynamic routing?

天涯浪子 提交于 2020-12-13 03:26:43
问题 Suppose I have a page that will show the details of each chapter in the book. User can navigate to other chapters from that page, as the screen has buttons of chapters in the sidebar, and the main content shows the details of the chapter. Now the user will navigate to that page from a list of books. At the page information, there's no chapter information of that book. Now if the URL is \bookSlug , so the page will show the details of the first chapter, even it is not mentioned in the URL, it

How can I specify the optional parameters in the dynamic routing?

僤鯓⒐⒋嵵緔 提交于 2020-12-13 03:25:55
问题 Suppose I have a page that will show the details of each chapter in the book. User can navigate to other chapters from that page, as the screen has buttons of chapters in the sidebar, and the main content shows the details of the chapter. Now the user will navigate to that page from a list of books. At the page information, there's no chapter information of that book. Now if the URL is \bookSlug , so the page will show the details of the first chapter, even it is not mentioned in the URL, it

What to change to prevent double request from service worker?

ぐ巨炮叔叔 提交于 2020-12-12 11:59:24
问题 Please do not mark as duplicate. This is not an exact duplicate of the other similar questions here on SO. It's more specific and fully reproducible. Clone this repo. yarn && yarn dev Go to localhost:3000 and make sure under (F12)->Applications->Service workers, the service worker is installed. Go to Network tab and refresh a few times(F5) Observe how the network requests are doubled. Example of what I see: Or if you want to do it manually follow the instructions below: yarn create-next-app

How can I configure Storybook.js Webpack to work with absolute image paths in CSS modules in a Next.js project?

醉酒当歌 提交于 2020-12-12 11:25:07
问题 I am trying to configure Storybook to work with Next.js, Ant Design, Less, and TypeScript. In Next.js, images have to be stored in the public/ folder and referenced with absolute paths to be used throughout the project. I am having trouble configuring the Storybook.js webpack to be able to resolve these absolute image paths. For example, in a CSS module I could have: .testImage { background-image: url('/images/cucumber.png'); background-repeat: no-repeat; background-size: contain; height:

How can I configure Storybook.js Webpack to work with absolute image paths in CSS modules in a Next.js project?

瘦欲@ 提交于 2020-12-12 11:25:05
问题 I am trying to configure Storybook to work with Next.js, Ant Design, Less, and TypeScript. In Next.js, images have to be stored in the public/ folder and referenced with absolute paths to be used throughout the project. I am having trouble configuring the Storybook.js webpack to be able to resolve these absolute image paths. For example, in a CSS module I could have: .testImage { background-image: url('/images/cucumber.png'); background-repeat: no-repeat; background-size: contain; height: