From 1defda2b11571d88ae9ccd2648b8f5bb12490375 Mon Sep 17 00:00:00 2001 From: The Coding Aviator <34807532+thecodingaviator@users.noreply.github.com> Date: Tue, 16 Oct 2018 14:23:57 +0530 Subject: [PATCH] Update index.md (#19453) --- .../index.md | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/client/src/pages/guide/english/certifications/front-end-libraries/react/use-the-lifecycle-method-componentdidmount/index.md b/client/src/pages/guide/english/certifications/front-end-libraries/react/use-the-lifecycle-method-componentdidmount/index.md index 68bd85ac38..edc5964fd9 100644 --- a/client/src/pages/guide/english/certifications/front-end-libraries/react/use-the-lifecycle-method-componentdidmount/index.md +++ b/client/src/pages/guide/english/certifications/front-end-libraries/react/use-the-lifecycle-method-componentdidmount/index.md @@ -3,8 +3,50 @@ title: Use the Lifecycle Method componentDidMount --- ## Use the Lifecycle Method componentDidMount -This is a stub. Help our community expand it. +This challenges introduces the ``` componentDidMount ``` Lifecycle method. This is used to set state after a giventime period. -This quick style guide will help ensure your pull request gets accepted. +The syntax for the method is: +```javascript +componentDidMount() { + setTimeout( () => { + this.setState({ + one: 1, + two: false + }); + }, interval); + } +``` +where ``` one ``` and ``` two ``` are states you want to set after ``` interval ```ms. - +### Hint + +Use +```javascript +this.state.stateName +``` +and change ``` stateName ``` as required. + +### Solution + +Change +```javascript +render() { + return ( +
+

Active Users: { /* change code here */ }

+
+ ); + } +``` + +to + +```javascript +render() { + return ( +
+

Active Users: { this.state.activeUsers }

+
+ ); + } +```