How to call Functions with parameter dynamically in ReactJS when selected a field
While selecting the element from the select drop-down, I stored that value in the state variables
<Select
onChange={e => setMessage(e.value)}
options={options}
>
After that, I need to call another function which this parameter and I did this, but it doesn't take any argument
<CallGetAMIDetails />
What will be the right syntax to execute the function with parameter
function CallGetAMIDetails(message)
This is wrong syntax <CallGetAMIDetails(message) />
Here is the full example code, what would be right thing to do to call this function function CallGetAMIDetails(message)
import React , { useState }from 'react';
import {DashboardLayout} from '../components/Layout';
import Select from 'react-select'
const options = [
{ value: 'ami-abc*', label: 'ami-abc' },
{ value: 'ami-xyz*', label: 'ami-xyz' },
]
const DiscoverAMIPage = () => {
return (
<DashboardLayout>
<h2>Discovered AMI</h2>
<Select
onChange={e => setMessage(e.value)}
options={options}
/>
<CallGetAMIDetails />
</DashboardLayout>
)
}
function CallGetAMIDetails(message) {
console.log(this.message)
}
export default DiscoverAMIPage;