I'm trying to write a modal window on React Js so that it appears immediately after the page loads. Checking like in native JS through window.onload = funciton () {} does not work.
In addition, I would like to ask about the correctness of my thinking: I create the ModalWindow component (for example) .js, write the markup there and in the render () {} I write the JS code. Then stylize and launch already in the component of the main page?
import React from 'react'; import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './Modal.css'; import Link from '../Link'; class Modal extends React.Component { static propTypes = { model: PropTypes.object.isRequired, }; render() { window.onload = function () { document.getElementsByClassName('closeBtn').onClick = function () { document.getElementsByClassName('modalWindow').style.display = 'none'; }; }; return ( <div className={s.modalWindow}> <div className={s.modal}> <h1>Modal window</h1> <p>fdsifjiodsjfiodsjiofjdsiojfioejwfiowejio jioewfjfiojewifwe jiowfj</p> <button className = {s.closeBtn}></button> </div> </div> ); } } export default withStyles(s)(Modal);