How you react will depend on the situation.
If you're climbing and you hear someone yell "ROCK" then your default reaction should be to hug the rock, brace for impact, and hope the rock misses you, or glances off your helmet.
If the call comes from above, you should repeat it in case your belayer didn't hear the person above you. If your belayer makes the call, you can judge the severity of your predicament by their tone. "Roooock..." Is generally the unconscious response to small stuff falling from the rock face, the little stuff that tinkles off your helmet, or a rock that someone kicks loose, but isn't falling in anyone's direction. "ROCK ROCK ROCK ROCK!!!" means that there is real danger of someone getting hurt from a larger rock falling, but those rocks are the ones usually accompanied by loud crashing sound as it bounces off the cliff face.
For the latter situation, your life or limb may depend on a quick reaction and the possibility of having to dodge the rock, even if that means jumping out of the way and taking a whipper. In those situations, it might not make much of a difference if the rock hits you in the helmet or in the face, so look quick and react accordingly. If you can hear the rock coming it's easier to judge how big it is and which way it's falling, and know where to look, but if you can't hear it, you may be safer to go with the default reaction.
Your default reaction should always be to get as close to the wall as possible, preferably under any sort of an overhang, get high on the wall, and brace for impact. You want to get high because you don't want to be straight armed if you get hit in the head. Your arms and legs can soak up some of the impact if your arms are bent and your legs straight at the time of impact, but if your arms are straight, then your neck is going to take all the impact, and likely pop you off the wall, which could result in additional injury as you plummet head first down from whence you came. The only time you would go low is if there was a feature right in front of you that you could duck under.
As a belayer, you should always be watching your climber and be aware of what's going on up above. The only time you shouldn't already be aware of whatever rocks may be falling, is when your leader is climbing out of sight. When a rock comes down, you should already be looking up, so judge its trajectory, and get out of its way if you need to. I've watched people lock off their ropes and just run for their life sideways to get out of the way of falling ice and rocks when belaying from the ground. But I've also seen people run 20 feet to the side just to get hit by the thing they were trying to dodge, so make sure you know which way the rock is falling.
For the small stuff that comes down on dirty routes, you can just tuck in your chin and let it bounce off your helmet. I've seen some people even point their helmet towards the wall to protect their faces from anything that might hit the rock right in front of them and bounce out towards them.
Judge your situation, and react accordingly, not getting hit by rocks will often require a modest dose of common sense, so be smart, and don't set yourself up to get hurt.