Moving to componentdidmount

ComponentWillMount is bound to be deprecated (hence UNSAFE) in the new React version so switching to componentDidMount is a solid plan.
This commit is contained in:
Karl Anders 2018-06-03 17:44:04 +02:00 committed by Rick van Lieshout
parent ecdf88a7e9
commit 36a8fae2b9

View File

@ -43,11 +43,11 @@ class CookieConsent extends Component {
};
}
componentWillMount() {
componentDidMount() {
const { cookieName, debug } = this.props;
// if debug desired or cookieName undefined
if (debug || Cookies.get(cookieName) === undefined) {
// if cookie undefined or debug
if (Cookies.get(cookieName) === undefined || debug) {
this.setState({ visible: true });
}
}