It generally becomes unenforceable. Many state legislatures will leave the law "on the books", but (in the case of a criminal code) it will not be enforced. For example, laws against sodomy, fornication and adultery are still on the books in almost all states despite having been declared unconstitutional in 2003 by the US Supreme Court.
Often, laws will be modified after a court ruling to comply with the court's guidance.
In some cases, such as abortion laws, many states have laws which run completely against the court rulings in Roe v. Wade and its progeny, but they leave them there as a statement of policy and the state's intent. These laws will often have language that says something to the effect of "if the supreme court changes its mind, then this is what the law will be" (obviously, it will be much more "official" than that).
13 years legal practice and work with state legislature