Peanut allergies are definitely genetic. But genes aren't the whole story. What happens to us plays a role in whether we'll be allergic to peanuts too.
...
First, peanut allergies tend to run in families. If you have a close relative with a peanut allergy, your risk of being allergic to peanuts is 7%. If you don't, then your risk is only 0.5%.
...
A recent study showed that if mom eats peanuts while pregnant, the risks for the child of being allergic to peanuts goes up 4-fold. For example, if the risk was 0.5%, it would now be 2%. [If the risk was 7%, it is now a 28% chance.]
And if mom eats peanuts while breastfeeding, then the child's risk goes up by 2-fold. If these studies hold up, then clearly being exposed to peanuts at an early age can increase a child's risk of being allergic later.