This is a hard lesson I had to learn as a junior developer.
I'm impatient and Stack overflow can often give me an easy solution. But just as often, it can't and I will spend 30 minutes unproductively trying things with little progress.
As I become a better developer I become more inclined to spend 30 minutes with the documentation instead.