server-side-rendering

Next.js Fetch data in HOC from server in SSG

泪湿孤枕 提交于 2020-08-27 06:38:59
问题 I created new app with Next.js 9.3.1 . In old app with SSR. I can you getInitialProps function in HOC components (not in page), so I can fetch data from server in HOC component and from page. Like this https://gist.github.com/whoisryosuke/d034d3eaa0556e86349fb2634788a7a1 Example : export default function withLayout(ComposedComponent) { return class WithLayout extends Component { static async getInitialProps(ctx) { console.log('ctxlayout fire'); const { reduxStore, req } = ctx || {} const

Next.js Fetch data in HOC from server in SSG

末鹿安然 提交于 2020-08-27 06:38:01
问题 I created new app with Next.js 9.3.1 . In old app with SSR. I can you getInitialProps function in HOC components (not in page), so I can fetch data from server in HOC component and from page. Like this https://gist.github.com/whoisryosuke/d034d3eaa0556e86349fb2634788a7a1 Example : export default function withLayout(ComposedComponent) { return class WithLayout extends Component { static async getInitialProps(ctx) { console.log('ctxlayout fire'); const { reduxStore, req } = ctx || {} const

How to redirect to login page for restricted pages in next.js?

≯℡__Kan透↙ 提交于 2020-08-21 20:28:25
问题 In the udemy tutorial The Complete React Developer Course the additional package history was used to get the router outside a component for redirecting when the user is not authenticated: /* AppRouter.js */ import createHistory from "history/createBrowserHistory"; const AppRouter = () => ( <Router history={history}> <div> <Switch> <PublicRoute path="/" component={LoginPage} exact={true} /> <PrivateRoute path="/dashboard" component={ExpenseDashboardPage} /> <PrivateRoute path="/create"

How to redirect to login page for restricted pages in next.js?

不问归期 提交于 2020-08-21 20:19:27
问题 In the udemy tutorial The Complete React Developer Course the additional package history was used to get the router outside a component for redirecting when the user is not authenticated: /* AppRouter.js */ import createHistory from "history/createBrowserHistory"; const AppRouter = () => ( <Router history={history}> <div> <Switch> <PublicRoute path="/" component={LoginPage} exact={true} /> <PrivateRoute path="/dashboard" component={ExpenseDashboardPage} /> <PrivateRoute path="/create"

How to redirect to login page for restricted pages in next.js?

蹲街弑〆低调 提交于 2020-08-21 20:19:04
问题 In the udemy tutorial The Complete React Developer Course the additional package history was used to get the router outside a component for redirecting when the user is not authenticated: /* AppRouter.js */ import createHistory from "history/createBrowserHistory"; const AppRouter = () => ( <Router history={history}> <div> <Switch> <PublicRoute path="/" component={LoginPage} exact={true} /> <PrivateRoute path="/dashboard" component={ExpenseDashboardPage} /> <PrivateRoute path="/create"

How to implement SSR for Material UI's media queries in NextJs?

末鹿安然 提交于 2020-08-07 05:15:25
问题 I can't follow the documentation of implementing Material UI's media queries because it's specified for a plain React app and I'm using NextJs. Specifically, I don't know where to put the following code that the documentation specifies: import ReactDOMServer from 'react-dom/server'; import parser from 'ua-parser-js'; import mediaQuery from 'css-mediaquery'; import { ThemeProvider } from '@material-ui/core/styles'; function handleRender(req, res) { const deviceType = parser(req.headers['user

How to implement SSR for Material UI's media queries in NextJs?

左心房为你撑大大i 提交于 2020-08-07 05:14:04
问题 I can't follow the documentation of implementing Material UI's media queries because it's specified for a plain React app and I'm using NextJs. Specifically, I don't know where to put the following code that the documentation specifies: import ReactDOMServer from 'react-dom/server'; import parser from 'ua-parser-js'; import mediaQuery from 'css-mediaquery'; import { ThemeProvider } from '@material-ui/core/styles'; function handleRender(req, res) { const deviceType = parser(req.headers['user

Next Js application build

那年仲夏 提交于 2020-08-05 10:02:50
问题 I am trying to deploy the next js application in firebase. For which I have made firebase.json like, { "hosting": { "public": ".next", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } } With assumption I have given .next as value for public but when running the app in firebase url, it says that the index.html file is missing like and hence throws page not found error, If I give dist then it throws error as there

DOMException: Failed to execute 'replaceState' on 'History': A history state object with URL

爷,独闯天下 提交于 2020-08-05 05:43:11
问题 The bounty expires in 15 hours . Answers to this question are eligible for a +100 reputation bounty. Harsimer wants to draw more attention to this question: Any type of guidance or explanation would be helpful In react app getting below error when opening cached version of webpage on google. DOMException: Failed to execute 'replaceState' on 'History': A history state object with URL 'https://projecturl' cannot be created in a document with origin 'https://webcache.googleusercontent.com' and

DOMException: Failed to execute 'replaceState' on 'History': A history state object with URL

橙三吉。 提交于 2020-08-05 05:43:08
问题 The bounty expires in 15 hours . Answers to this question are eligible for a +100 reputation bounty. Harsimer wants to draw more attention to this question: Any type of guidance or explanation would be helpful In react app getting below error when opening cached version of webpage on google. DOMException: Failed to execute 'replaceState' on 'History': A history state object with URL 'https://projecturl' cannot be created in a document with origin 'https://webcache.googleusercontent.com' and