Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!