It doesn't though, it's the illusion of removing of a dependency which is rather dangerous. You're not only swapping one dependency for another in this specific case, but you're ignoring the rest of the global economy and its own dependencies and how they affect you.
Eh, an operational dependency that immediately raises costs across your entire economy, across all geographies, all industries, within a couple days of disruption is very different from these more strategic dependencies.
The key would be to simply not ignore all the other dimensions of dependency.
You're swapping a dependency which hits very quickly if disturbed, for one that would take a much longer time to manifest.
When Russia invades Ukraine or Iran cuts the straight of Ormuz energy prize go up instantly, chocking the entire world economy in the course of a few weeks. Even if China stops exporting rare earths, it would take years before it affects the energy market.
It's absolutely incomparable.
Cuba is a good example by the way: a country can survive for decades while being cut from most technology import due to sanctions, but if you cut its access to oil, it becomes dirty real quick. And because Cuba has been stuck in the middle of the 20th century, it's actually much less dependent on energy than most developed or even developing countries.
A country that goes all in renewable is in a stronger positon. UK power grid doesn't give a fuck about this war.
Sure China. But unless they send in an army to retreive previously sold panels, or block the sun they can only harm future increases to supply.