Skip to content Skip to sidebar Skip to footer

React Resize Change Components

I have a React App where I have an event listener for resize event on the window object. class App extends React.Component { constructor(props){ super(props); this.state

Solution 1:

      render() {
        let content = this.state.width < 600 ? <MobileComponent/> : <DesktopComponent />;
        return(<div>
            <div>{content}</div>
            <childComponent myWidth= {this.state.width}></childComponent >
            <childComponent2 myWidth= {this.state.width}></childComponent2 >
       </div>
      )
 }

Post a Comment for "React Resize Change Components"