Created
December 30, 2018 18:32
-
-
Save Kornil/7c567de43a4758fa810558b107c73660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, createContext } from "react"; | |
const ModalContext = createContext({ | |
hideModal: () => null, | |
show: false, | |
showModal: () => null | |
}); | |
export default ModalContext; | |
export class WrapperModal extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
hideModal: this.hideModal, | |
show: false, | |
showModal: this.showModal | |
}; | |
} | |
hideModal = () => { | |
this.setState({ | |
show: false | |
}); | |
}; | |
showModal = () => { | |
this.setState({ | |
show: true | |
}); | |
}; | |
render() { | |
const { children } = this.props; | |
return ( | |
<ModalContext.Provider value={this.state}> | |
{children} | |
</ModalContext.Provider> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment