When I am clicking on button 2 first it is calling function 1 not function 2, I want if click button1 should call function 1 and if click on button2 should call function 2
it is working fine if click button 1 first then button 2 next, but it is calling function 2 if I click button 2 first
const function1 =()=>
{
alert('function 1 called')
}
const function2 =()=>
{
alert('function 2 called')
}
parent Component
const ParentComponent = () =>
{
return(
<ChildComponent onChange={function1} />
//Button 1
<ChildComponent onChange={function2} />
//Button 2
)
}
child Component
const ChildComponent = (props) =>
{
return(
<>
<div className='button'>
<label htmlFor='single'>
<FontAwesomeIcon icon={faImage} color='#3B5998' size='5x' />
</label>
<input type='file' id='single' onChange={props.onChange} />
</div>
</>
)
}
id='single'
this part should be unique per DOM element.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments