I have two functions that I want to run when user selects option. I have tried with a conditional. It looks something like this, but the h2 doesn't render.
function a() {
// some logic
return <h2>{result of some logic}</h2>;
}
function b() {
// some logic
return <h2>{result of some logic}</h2>;
}
handleChange(e) {
if (e.target.value == "a") {
a()
}
else if (e.target.value == "b") {
b()
}
}
return (
<select onChange={handleChange()}>
<option value="a">a</option>
<option value="b">b</option>
</select>
)
<h2>to do? (Right now,handleChange()doesn't use it, and it will just be discarded)