I have a small problem when trying to send my props and functions to a functional component, they will see. I want to have the state and functions in a Component and the interface in a Functional Component , my question is How do I send the properties of the Component to the Functional Component?
Then I put my code so they can help me, many thanks in advance!
import React, { PureComponent } from "react";
import ModalComponent from "../../components/ModalComponent";
class ModalContainer extends PureComponent {
state = {
open: false
};
handleOpen = () => {
this.setState({ open: true });
};
handleClose = () => {
this.setState({ open: false });
};
render() {
return (
<ModalComponent
open={this.state.open}
handleOpen={this.handleOpen}
handleClose={this.handleClose}
/>
);
}
}
export default ModalContainer;
And my ModalComponent, which is what I want to receive the properties. (I will not put the other part of the code so as not to interfere with distractions)
function ModalComponent(props) {
const { classes } = props;
return (
<div>
<Button onClick={props.handleOpen}>Open Modal</Button>
<Modal open={props.open} onClose={props.handleClose}>
<div style={getModalStyle()} className={classes.paper}>
{props.children}
</div>
</Modal>
</div>
);
}