Check out example codes for "why do you jerk while falling aslee". It will help you in understanding the concepts better.
Code Example 1
Another popular idea takes a more evolutionary approach to hypnic jerks, explaining that the spasms are an ancient primate reflex to the relaxation of muscles during the onset of sleep — the brain essentially misinterprets the relaxation as a sign that the sleeping primate is falling out of a tree, and causes the
Learn ReactJs, React Native from akashmittal.com