Then when he says, While you have the light, believe in the light, he explains what he said, namely, what it means to walk. This is explained in two ways, according to the two explanations given above. According to the first explanation: While you have the light, that is, while you have some knowledge and light of the truth, believe in the light, that is, in the complete truth, that you may become sons of light, that is, that you may be reborn in the truth: "We are not of the night or of darkness. So then let us not sleep" (1 Thess 5:6).
Or, according to the other explanation: While you have ...the light, that is, me who am the light - "He was the true light which enlightens every man who comes into the world" (1:9) - believe in the light, that is, in me. In other words, make progress in the knowledge of me, that you may become sons of light, because from the fact that you believe in me you will be the children of God: "But to all who receive him, who believed in his name, he gave power to become children of God" (1:12).
When Jesus had said this, he departed and hid himself from them. Here the Evangelist tells what Jesus did, that he hid himself. When we read above (8:59) that Christ did this very thing, the reason was obvious, for they were taking stones to cast at him. But here there is no reason for his hiding given, such as that they took up stones or that they blasphemed him. Why then did he hide? The answer is that our Lord, seeing into their hearts, knew their rage and the evil they had planned, i.e., to kill him. And so in his desire to stop them he did not wait for them to act, but hid himself so their anger and envy would abate. In doing this he is an example to us that when the evil purposes of others are clear to us, we should flee before they can accomplish them. In addition, our Lord was showing by his actions what he had said by his words. For he just said, Walk while you have the light, lest the darkness overtake you. And by hiding himself he indicated what sort of darkness he means: "I will wait for the Lord, who is hiding his face from the house of Jacob" (Is 8:17).
Source: Commentary on John