I have a functional component inside which I have a button. I want to call a functional component when that button is clicked.
When we click Submit button the Preview button shows up and when the user clicks the preview button then Preview functional component is called.
const Form =(props)=>{
handlePreview=(e)=>{
e.preventDefault();
return <Preview/>
}
return(
<input name="email" type="text"/>
<button type="submit" onClick={props.handleSubmit}>Submit</button><br/>
{props.render&&
<button type="submit" onClick={handlePreview}>Preview</button>
}
)
}
When I click the Submit button the Preview Button shows up but when I click the Preview Button it doesnt navigate to the <Preview> functional component
Previewcomponent into theFormif you wish to render them conditionally, and control viastate