Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
How to remove initialisations on page change in Next JS

I am trying to use OneSignal for notifications and they initialise it like this....

OneSignal.push(function () {
  OneSignal.init({
    appId: self.props.data.pushAppId,
    notifyButton: {
      enable: true,
    },
    allowLocalhostAsSecureOrigin: true,
  })
})

Which works great cause I only want it shown in certain pages so it lives in componentDidMount. When I navigate away from that page it doesn't remove the bell notification so it continues to exist on pages that I do not initialise it on.

How can I (in componentWillUnmount i'm guessing) remove the instance of it gets destroyed on page change.

It will remove on hard refresh of other pages but router changes it doesn't get removed.

Thanks

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda