Social media has made it worse. I think that it encourages preference falsification and causes inelasticity in the Overton Window. That inelasticity means that changes in public opinion are abrupt and usually need some concrete excuse to be justified.
"The Page Act becomes law. It's the country's first exclusionary act, banning criminals, prostitutes, and Chinese contract laborers from entering the country. 1882. Congress passes the Immigration Act."
That said, I think if the US had a strict policy like any number of countries where you can presume 90%+ of immigrants are legal, people would treat immigrants much better knowing they didn't shortcut the system, they have government imprimatur and that they contribute to the economy and to other Americans' wellbeing.
But... regardless, we should always proceed civilly and petition the gov't rather than lash out on a population, legal or not.
For example, in England /UK we witness outlash toward Poles, despite their not being outwardly different, but for language. Again, lower classes feel undue labor pressure and take it out on working class immigrants.
There is a debate to be had about who and how and how many people from where we allow to settle. We are outliers in how many people we take in. And I think we should tailor policies with the impact on Americans in mind.
We're no longer in a steep growth phase, we're a mature economy which can successfully absorb so many new people into viable jobs. We need to work harder to get our underemployed better employed before we employ the surplus workers from elsewhere.
That's not to say no immigration. Just controlled and proportional to need and population of origin so that both a Senegalese and Indian and Cuban have reasonable equality in obtaining a visa.
There is no reason we can't set data driven quotas to allow, say, 2MM per annum to fill needs for ditch diggers and doctors, etc. But base it on need and do it with some balance.