“And from the people is he who worships Allah as if he were on an edge (i.e. in doubt): if good befalls him, he is content with it. And if a trial befalls him, he turns back on his face. He loses both this world and the Hereafter. That is the clear loss.” (Qur’an, 22:11)
Commenting on this verse, Ibn Kathir said in his Tafsir (3/279): Such a person enters the religion on an edge. So, if he finds what he likes, he sticks with it. Otherwise, he retreats. Al-Bukhari reported that Ibn Abbas said, “A man would come to Madina. If his wife gave birth to a son and his mare gave birth to foals, he would say, ‘This is a good religion.’
If his wife didn’t give birth and his mare didn’t either, he would say, ‘This is a terrible religion.’” Ibn Abbas also said, “Some bedouins would come to the Prophet and become Muslims and then they would return to their homelands.
If they returned to a year of rain, produce, and good children being born, they would say, ‘This religion of ours is good. So, stick to it.’ If they came back to a year of hunger, bad children being born, and drought, they would say, ‘There is no good in this religion of ours.’ So, Allah revealed this (the above) verse.”
Abdul Rahman Bin Zayd Bin Aslam said (about this verse): “This is with regard to the hypocrite. If everything is going well for him in his life, he is consistent in his worship.
If things change and go bad for him, he goes back and wavers in his worship, except when things are going well.
So, if a trial, hardship, test, or inconvenience befalls him, he abandons his religion and returns to kufr (disbelief).”