It's like a switch is flicked

My 10 year old has recently been getting angry or upset completely out of the blue like someone has just flipped a switch. For example, we went to my friend's house and he went in their pool as was laughing and having a lovely time then all of a sudden he got out and started shouting "I am never going in that pool again and i want to go home". After a few minutes of this he got back in and was happy again. 

We can be doing something he appears to be enjoying and suddenly he will run upstairs, slam the door and barricade himself in his room or run in the garden and lock himself out there.  

He gets cross if we ask him what is the matter and he gets cross if we don't!

Sometimes we can get through to him on What's App where he bombards us with emojis !

It's like parenting on egg shells as we don't know how when or if he will flip.