And if you sell bonds for yuans that causes the yuan's value to raise which hurts Chinese exporters. So, devaluating it first was a way of neutralizing that effect, protecting China's economy.
Bond sale itself was a way of putting mild pressure on US in the ongoing negotiations about making Yuan part of world's reserve system.
China didn't just "start selling US treasury bonds". You're implying that they're offloading their bonds, they are far from it. China sold off an insignificant portion of their holdings for liquidity to bail out themselves. They were facing an economic crash and they were trying to stave it off. They needed cash to do that, hence, they sold a very specific amount of their bonds for that specific purpose.
If they sold all of their treasury bonds, it would be economic suicide because there would be so much unstableness in the global economy that every market would crash, including Chinas. They would probably fall the hardest, too.