Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Development
SSH-WEB
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="MayoMayn" data-source="post: 435777" data-attributes="member: 71840"><p>Just to mention, if you're going to do async stuff, you should do it inside componentDidMount and not componentWillMount as it gets called multiple times and the rendering is most definitely finished before the async stuff is.</p><p>Referring to your redux function that looks like a HTTP request inside your DeviceDashboard component.</p><p></p><p>E.g</p><p>[PHP]</p><p>class DeviceDashboard extends Component {</p><p></p><p> componentDidMount = () => this.props.fetchDevices();</p><p></p><p> // ...</p><p></p><p> render = () => (</p><p> <div className="dashboard"></p><p> <div className="container"></p><p> // check the loading property instead of the devices length</p><p> {this.props.loading ? <h1>Loading...</h1> : this.createDeviceDashboard()}</p><p> </div></p><p> </div></p><p> );</p><p></p><p>}</p><p>[/PHP]</p><p>and then set the loading property as true in the initial state</p><p></p><p><a href="https://stackoverflow.com/a/41612993" target="_blank">https://stackoverflow.com/a/41612993</a></p></blockquote><p></p>
[QUOTE="MayoMayn, post: 435777, member: 71840"] Just to mention, if you're going to do async stuff, you should do it inside componentDidMount and not componentWillMount as it gets called multiple times and the rendering is most definitely finished before the async stuff is. Referring to your redux function that looks like a HTTP request inside your DeviceDashboard component. E.g [PHP] class DeviceDashboard extends Component { componentDidMount = () => this.props.fetchDevices(); // ... render = () => ( <div className="dashboard"> <div className="container"> // check the loading property instead of the devices length {this.props.loading ? <h1>Loading...</h1> : this.createDeviceDashboard()} </div> </div> ); } [/PHP] and then set the loading property as true in the initial state [URL]https://stackoverflow.com/a/41612993[/URL] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Development
SSH-WEB
Top