California will likely be under central Mexican government authority by then. Whether it'll secede on its own or a declining U.S. surrenders it to Mexico is anyone's guess. Either way, I can't imagine a scenario in which CA is still a part of what remains of the U.S. in 2040.
The scenario might well be that all the illegal and legal Mexican immigrants to California aren't fools, and they will not want to again live under the corrupt Mexican government and the failed Mexican economy.
Even though current trends will diminish California more and more, it will still be preferable to Mexico for many decades to come.