What you eat and the timing of eating depends on various factors. Snack bars like Clif and others take a bit longer to digest and convert to usable fuel. I usually prefer to nibble those a little at a time throughout a ride.
Gels and plain sugar work quicker, so when you feel a bonk coming on (depletion of fuel) those are the snacks or drinks to use.
Here's an interesting GCN video from a few months ago in which Conor and Hank rode 140 km (87 miles) with Conor only drinking, no eating; while Hank ate whatever he wanted. And this wasn't an entirely casual paced ride -- it included various harder efforts to check blood sugar levels and depletion throughout the ride.