Getting proper nutrition during a long workout or race can help you extend your endurance, as well as maintain body temperature, electrolyte balance, pace, and RPE (rate of perceived exertion). Best of all, on-the-go fuel can help keep you smiling all the way to the finish.
Fueling during a race is one of the most difficult things to get right. Don't wait until you're hungry to start fueling. Try to eat early, often, and according to a pre-determined and practiced plan. Unfortunately, there's no single fueling strategy that works for everyone. Sports drinks, energy gels, bars, blocks, and chews are great options for many athletes, while others swear by pretzels, dried fruit, granola, and bananas. Some people never race without flat Coca-Cola—you'll have to experiment to find what's best for you.
If you're going to compete for longer than 30 minutes, and/or at a very high intensity, studies show that sports drinks may be a better bet than plain water. They contain carbohydrates and electrolytes to help fuel your muscles, increase your desire to drink, and facilitate fluid absorption. The final rule is this: if you find something that works for you, stick with it!