I have a material-ui button and am trying to pass some parameter to my callback function on click.
For some reason, the below way is not working.
const myApi = async (param) => {
}
<Button onClick={myApi('text')}
data-testid='my-field'>
<Icon accessibleText="__label__search" name="search" size={12} />
</Button>
Use
onClick = {() => myApi("text")}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.