If your passport expires later, your ESTA remains valid only until that passport expires.
ESTA approvals are generally valid for up to two years, but they end earlier if the passport expires first.
That means you cannot keep using the old ESTA after the passport has expired.
If you receive a new passport, you must submit a new ESTA application using the new passport information.
For that reason, in an ESTA passport expires situation, it is important to check both your passport validity and your ESTA status before travel.