I'm trying to pass a variable from a function to my React return() function. I'm not sure what the best way to do this is:
class SaveOfferModal extends Component {
toggleSuccess() {
const { initialValues, formValues } = this.props;
if (initialValues !== formValues) {
const getChangedValues = diff(initialValues, formValues);
const showChangedValues = JSON.stringify(getChangedValues, 0, 2);
console.log(showChangedValues);
}
this.setState({
success: !this.state.success
});
}
render() {
return (
<Button
color='success'
onClick={this.toggleSuccess}
disabled={isDisabled}
className='saveOfferBtn'
>
Save Offer
</Button>
)
}
Thanks! I'm trying to pass the getChangedValues variable to the return() function!
stateorpropsto do that when you are using React. Do as Romans do.return()function