nextjs

How to set up Google Analytics through Google Tag Manager for Next-Js?

∥☆過路亽.° 提交于 2021-02-18 05:05:20
问题 formerly I was using react-ga npm module to insert google analytics in my next js app. and It was simply like this: import ReactGA from 'react-ga' export const initGA = () => { ReactGA.initialize('UA-*******-*', { titleCase: false }) } export const logPageView = () => { if (window.location.href.split('?')[1]) { ReactGA.set({page: window.location.pathname + '?' + window.location.href.split('?')[1]}) ReactGA.pageview(window.location.pathname + '?' + window.location.href.split('?')[1]) } else {

How to set up Google Analytics through Google Tag Manager for Next-Js?

左心房为你撑大大i 提交于 2021-02-18 05:04:53
问题 formerly I was using react-ga npm module to insert google analytics in my next js app. and It was simply like this: import ReactGA from 'react-ga' export const initGA = () => { ReactGA.initialize('UA-*******-*', { titleCase: false }) } export const logPageView = () => { if (window.location.href.split('?')[1]) { ReactGA.set({page: window.location.pathname + '?' + window.location.href.split('?')[1]}) ReactGA.pageview(window.location.pathname + '?' + window.location.href.split('?')[1]) } else {

Updating state in reducer using variables

旧时模样 提交于 2021-02-09 10:32:56
问题 I'm build a simple app that expands and collapses sections of content based on their state. Basically, if collapse = false, add a class and if it's true, add a different class. I'm using Next.js with Redux and running into an issue. I'd like to update the state based on an argument the action is passed. It's not updating the state and I'm not sure why or what the better alternative would be. Any clarification would be great! // DEFAULT STATE const defaultState = { membership: 'none',

Using getInitialProps in Next.js with TypeScript

六眼飞鱼酱① 提交于 2020-03-13 05:50:08
问题 From the documentation, Next.js 5.0 announcement and various articles around on the internet it seems like Next.js supports TypeScript well and many people are using it. But these threads suggest that getInitialProps , which is vital to Next.js apps, doesn't work: https://github.com/zeit/next.js/issues/3396 https://github.com/zeit/next.js/issues/1651 https://github.com/DefinitelyTyped/DefinitelyTyped/issues/23356 How can I fix it? In both class and functional components, when I do

Using getInitialProps in Next.js with TypeScript

懵懂的女人 提交于 2020-03-13 05:49:05
问题 From the documentation, Next.js 5.0 announcement and various articles around on the internet it seems like Next.js supports TypeScript well and many people are using it. But these threads suggest that getInitialProps , which is vital to Next.js apps, doesn't work: https://github.com/zeit/next.js/issues/3396 https://github.com/zeit/next.js/issues/1651 https://github.com/DefinitelyTyped/DefinitelyTyped/issues/23356 How can I fix it? In both class and functional components, when I do

Nextjs: Unable to load images from static folder

為{幸葍}努か 提交于 2020-02-29 22:02:50
问题 How can I load images in a component in Next.js? Do I have to build the project first? If yes, is there a way to load the images without building first? I cannot get this to work, no matter what I try. 回答1: from the docs: Just place your files in static directory then you can reference them in your app like: <img src="/static/my-image.png" /> I think next.js will have a watch on this directory so I don't think you need to re start your server every time you put something in there. But of

NextJS - Set dynamic environment variables at the start of the application

被刻印的时光 ゝ 提交于 2020-02-02 13:22:45
问题 In our implementation process we created a single building and went through the different stages (integration, staging and production). In each of the environments, we have variable environmental differences. The problem is that when we started the server it only referred to the environment variables on the server, but in the client the process.env file is empty. stack: "next": "5.0.0" "babel-plugin-inline-dotenv": "1.1.1", for load .env file is used "inline-dotenv" 回答1: You can use

NextJS - Set dynamic environment variables at the start of the application

丶灬走出姿态 提交于 2020-02-02 13:22:06
问题 In our implementation process we created a single building and went through the different stages (integration, staging and production). In each of the environments, we have variable environmental differences. The problem is that when we started the server it only referred to the environment variables on the server, but in the client the process.env file is empty. stack: "next": "5.0.0" "babel-plugin-inline-dotenv": "1.1.1", for load .env file is used "inline-dotenv" 回答1: You can use

Webpack breaking in IE11

这一生的挚爱 提交于 2019-12-12 13:33:55
问题 It's difficult to track this down, so thanks for bearing with me. Some users were complaining that our site was broken in IE11. The app is using nextjs 3.0.1 and webpack 2.7.0. Debugging in development mode I think I have an issue similar to Angular RxJs timer pausing on IE11. I'm getting an error from a reference called webpack///webpack bootstrapxxxxxxxxxx (where the x's are some numbers in hex) in IE11. Here's the function that's causing the issue: // The require function function _

How to defer this.props.onClick() until after a CSS animation is complete?

筅森魡賤 提交于 2019-12-11 10:58:23
问题 I am calling a custom NanoButton component from my page along with an onClick instruction to route to another page: // Page.js import { Component } from 'react'; import Router from 'next/router'; class Page2 extends Component { render() { return( <NanoButton type="button" color="success" size="lg" onClick={() => Router.push('/about')}>About</NanoButton> ) } } When the button ( NanoButton component) is clicked, I want to execute some internal code before moving on to the onClick coming in as