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

300
Views
Error: Chats(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null

The main error is in useEffect function its throwing error

i was creating a web chat aplication by following this yt - https://www.youtube.com/watch?v=Bv9Js3QLOLY&list=PL4nE3wz01AwBbgaAMROTVrhE4aTFRJx7x&index=8

http://localhost:3000/static/js/main.chunk.js:356:7

view source (the error is)

 353 | Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(() => {
  354 |   _firebase__WEBPACK_IMPORTED_MODULE_2__["auth"].onAuthStateChanged(user => {
  355 |     setUser(user);
> 356 |     setLoading(false);
  357 |    ^if (user) history.push('/Chats');
  358 |   });
  359 | }, [user, history]);

view compiled

   useEffect(() =>{
        auth.onAuthStateChanged((user) =>{
            setUser(user);
            setLoading(false);
            if(user) history.push('/Chats'); 
             
        })

    },[user ,history]);


AND THE WHOLE CODE IS DOWN BELOW

import { useHistory } from 'react-router-dom';
import { auth } from '../firebase';




const AuthContext = React.createContext();

export const useAuth =() => useContext(AuthContext) ;

export const AuthProvider =({ children }) =>{

    const[loading, setLoading] = useState(true); 
    const[user, setUser] = useState(null);
    const history = useHistory();


    useEffect(() =>{
        auth.onAuthStateChanged((user) =>{
            setUser(user);
            setLoading(false);
            if(user) history.push('/Chats'); 
             
        })

    },[user ,history]);


    const value = { user };


    return(
         <AuthContext.Provider value={value}>
             {!loading && children}
         </AuthContext.Provider>
    );

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

0

Your useEffect should return a function, which React will then run when it unmounts the component. Luckily that is precisely the type of function that auth.onAuthStateChanged returns, so you can do:

return auth.onAuthStateChanged((user) =>{
  ...
about 4 years ago · Juan Pablo Isaza Report

0

i think your useEffect is throwing an error because you are running it every time history change and inside the useEffect you are changing history so it creates a loop and thats an error, comment the error here so it will be more easy to someone to help

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!