While depending on China for Solar panels is of course a liability, it's a very very different liability from relying on fossil fuel imports.
A solar panel has an effective lifetime of 20-30 years. A barrel of oil is literally set on fire.
If China stopped selling solar panels, there wouldnt be any energy crisis, just an inability to install *new* panels.
Same goes for the battery dependencies we have on Chinese imports.
Not a perfect situation of course, but there are some clever things the EU is doing about it. For instance, the recycling requirements is creating a local industry of people who intimately know all the components and construction of Chinese panels and batteries, and these people will be vital in kickstarting the domestic industry if China tries something. It also means that we're getting better and better at recovering rare earth minerals from decommissioned products, and we are building domestic reserves.