Skip to main content

Posts

Showing posts from August, 2022

react event handler

  import React from 'react' ; class Clock extends React . Component {   state = {date : new Date (),locale : 'bn-BD' };         componentDidMount (){         this . clockTimer = setInterval (() => this . tick (), 1000 );     }     componentWillUnmount (){         clearInterval ( this . clockTimer );     }     tick (){         this . setState ({             date : new Date (),         });     }     handelClick = () => {         this . setState ({           locale: 'en-US' ,         });     }   render () {     const { data , locale } = this . state ;     return (       < div >         < h1 className = 'heading' >   ...

react class component

  import React from 'react' ; import ReactDOM from 'react-dom' ; const index = 0 ; class Clock extends React . Component {   render () {     return (       < h1 className = 'heading' tabIndex = { index }>         < span className = 'text' >Hello { new Date (). toLocaleTimeString ( this . props . locale )}</ span >       </ h1 >     );   } } ReactDOM . render (< Clock locale = "bn-BD" />, document . getElementById ( 'root' ));

React class

  import React from 'react' ; import ReactDOM from 'react-dom' ; const index = 0 ; class Clock {   print () {     return (       < h1 className = 'heading' tabIndex = { index }>         < span className = 'text' >Hello { new Date (). toLocaleTimeString ()}</ span >       </ h1 >     );   } } const ClockComponent = new Clock (); ReactDOM . render ( ClockComponent . print (), document . getElementById ( 'root' ));

React element