The Wikipedia page for locally constant function says that a locally constant function is constant on each connected component, but that the converse only holds if the space is locally connected. What would be an example of a function that is constant on each connected component but not locally constant?
I first thought of the topologist's sine curve, which is not locally connected, but since this is a connected space, such a function would be constant on the entire space and therefore automatically locally constant.