It's not the same. The Soviets inspired a level of cultural disgust and existential terror in the US that China just can't match. We not only wanted to discredit communism by winning the space race, but make sure they couldn't glass us from orbit the first chance they got.
You ask the average American whether or not they'd pitch in to beat China to Mars and they'd say no. We don't have the nationalism to make that work anymore.
The key to why the space race worked is competition between nations. It's because the fallout from World War 2 was a strong sense of national identity. The same thing that made McCarthyism work is what made the space race work.
We don't have that anymore. It was probably a worthwhile trade: there are other vectors we can get technological advance from: but if Obama made a speech about beating China to Mars tomorrow as a proof of how America is a great nation, the Republicans would assemble on the dot to burn him at the stake for it.
There's still a sense of national identity, such as can be seen in the Olympics, but it's barely an echo of what it was 50 years ago. Before we lost in Vietnam. Before the Civil War was re-enacted to gain universal suffrage. Before Reaganomics. Before Cuba. Before Bosnia. Before 9/11 and Iraq. Before Snowden. Before Ferguson.