Answers for "react timeout function"

1

react timeout function

useEffect(() => {
  const timer = setTimeout(() => {
    console.log('This will run after 1 second!')
  }, 1000);
  return () => clearTimeout(timer);
}, []);
Posted by: Guest on August-05-2020
1

settimeout react example

import React, {Component} from 'react';

import Router_App from './Router';
import "./App.css";


class App extends Component {
  constructor(props){
    super(props);
    this.state = {
      timePassed: false
    };
  }

  render() {
    setTimeout(() => {this.setState({timePassed: true})}, 1700);
    if (!this.state.timePassed){
      return (
        <div style={{textAlign:"center",marginTop:"15%",fontSize:"5.5rem"}}>
       <p>M E A N I N G <br/>O F<br/> C O D E</p>
       </div>
      );
    }else{
      
      return (
       <Router_App/>
      );
  }
  }
}
export default App;
Posted by: Guest on May-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language