Sitecore headless - Few use cases for useEffect hook in the application head
If you use a framework like ReactJS, you probably don't need an introduction about hooks. Out of all the hooks, useEffect will sweep your feet off the floor. This is because of useEffect' power and capability to run side effects. Personally speaking, useEffect seemed like a swiss knife to me since anything I couldn't resolve using CSS / Javascript especially in lines of DOM manipulation, i normally looked upto useEffect and it never failed to disappoint me. In this note, I've covered a few such scenarios so that in future, when you encounter complex scenarios, you would then know which hook to approach as a last resort. Note that most of the scenarios listed here are technically similar since they deal with adding/removing css or some kind of html DOM manipulation but I wanted to cover this as a note in order to look at the variety of scenarios possible. Now, the advantage of ReactJS is, you can either add the useEffect code to layout.tsx as-is (not liked by purists si...