California, where the anti-Chinese racism was greatest, became a very crucial swing state during presidential elections, and therefore both parties had to court California.
As the Chinese grew in numbers, the immigrant population grew to the extent that it became a huge economic threat, there were efforts among white workers to organize among themselves politically, and what was unfortunate was that both major parties adopted anti-Chinese platforms.