It has been observed through various studies & research that both hereditary & near work/modern lifestyle can be the reasons for refractive errors. Because twins and relatives are more likely to get myopia under similar circumstances, there must be a hereditary factor.
The "near work" hypothesis, also referred to as the “use-abuse theory” states that spending time involved in near work strains the eyes and increases the risk of myopia. Some studies support the hypothesis while other studies do not. While an association with near work is present it is still unclear.