Clear console for every pages loaded (asynchrone api print)

Viewed 22

I have a reactJS app, traditional structure,

App.tsx index.tsx etc..

I use some private lib, and unfortunatly they print some data in the console that I dont want to show to our users. (like some object structure, or some debug)

I'm looking for a simple way to clear the console everytimes a page is loaded so at least It will look "empty"

Problem is the API send some prints after so my console is clear, but I see print just after

1 Answers

use console.clear() after page loaded.

EDIT:

Whenever API data updates you can clear via useEffect.

  const [apiList, setApiList] = useState([]);
  
  useEffect(() => {
    fetchApiData() // call api request...
    console.clear();
  }, [apiList]);
Related