As per the React Native docs at the time of writing:
If you already have a JDK on your system, we recommend JDK17. You may encounter problems using higher JDK versions.
As you can see from other answers, this may change as React Native is updated.