Assuming, as one probably should, that Donald Trump didn't just mean rare earths, but was talking more broadly about "critical minerals" (the two are different things, but let's not get too pedantic here), there are also one or two other promising mine sites in the country.
The entire market is small - making it essentially implausible that, even if Ukraine suddenly produced the majority of the world's supply, the president could expect that amount of revenue back in return.
Lend-Lease during WWII, aid during the Vietnam and Korean Wars, and even the first Gulf War, involved significantly bigger outlays than currently being spent on Ukraine.
And even if you presumed they could do, Ukraine would still be a relative minnow in global rare earths production.
President Trump has been talking recently about recouping $500bn from Ukraine in the form of revenues from mining rare earth metals.