Have a simple search bar (input field) which should trigger an onSubmit action while we press Enter button
You can use onKeyPress.
Check this : https://stackoverflow.com/questions/13987300/how-to-capture-enter-key-press
Simple, have a button type submit inside the form. Here's an example:
const onSubmit = () => {}
// ..
<form onSubmit={onSubmit}>
...
<button type="submit">Search</button>
...
</form>
You don't need to use onKeyPress event.