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

149
Views
I have multiple useEffect, listeners or handlers of service but in the same component

please help me with this question please i have multiple useEffect and handler of services like subscriptions, listener of network state, listener of state of redux, and other things the component have more of 400 lines, but in same component, the component is located in the home of app, but return null, just handle this services, i want know if this is right, and not is a bad practice, if this is incorrect, what is correct way for handle this kind listener or services directed for all the app there are a little example:

import React, {useEffect} from 'react'

export default function handlerServices() {

useEffect(() => {
  const unsubscribe = NetInfo.addEventListener(state => {
    setStateReduxNetwork(state);
  });
},[])
useEffect(() => {
  getInitialDeepLink();
   
  return () => {
    linkingSub.remove();
  };
}, []);
.....

.....
  
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's not necessarily bad practice. I've heard this called a 'utility component'. There are a couple of ways to possibly improve it.

  1. Split up the component by function so it's easier to trace errors. E.g. NetworkStateComponent, LinkingComponent, etc.
  2. Use an async action handling library like redux-sagas. I recommend that one if you already use redux and you need more handling than subscribe/unsubscribe.

This might also be a better question for the code review Stack Exchange.

about 4 years ago · Juan Pablo Isaza Report
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!