Posts

Showing posts from October, 2022

Log in

  import React , { useState } from ' react ' export default function FullFormFunction () {     const [ state , setState ] = useState ({     form : {               email : "" ,         password : "" ,         confirmPassword : "" ,         } ,       formErrors : {         email : null ,         password : null ,         confirmPassword : null ,                   }     });         var   handleChange = e => {         const { name , value , checked } = e . target ;         const { form , formErrors } = state ;         let formObj = {};                   formObj = {         ...

change bg by click

  import React , { useEffect , useState } from ' react ' import ' bootstrap/dist/css/bootstrap.min.css ' ; export default function Input () {     const [ colour , setColour ] = useState ( ' rgb(128, 255, 0) ' )   const handleClick = () => {     const randomColour = ' rgb( ' + Math . random () . toString ( 5 ) . slice ( 2 , 5 ) + ' , ' + Math . random () . toString ( 5 ) . slice ( 2 , 5 ) + ' , ' + Math . random () . toString ( 5 ) . slice ( 3 , 5 )   + ' ) '     setColour ( randomColour )   }   console . log ( colour );     useEffect (() => {     document . body . style . backgroundColor = colour   } , [ colour ])   return (     < >     < button className = ' btn px-20 py-20 ' onClick = { () => handleClick () } > color change </ button >     </ >   ) } const root = ReactDOM . createRoot ( document . getEl...

Full form

  import React , { useState } from ' react ' import ReactSelect from " react-select " ; export default function FullFormFunction () {     const [ state , setState ] = useState ({     form : {         name : " divyesh " ,         email : "" ,         mobile : "" ,         password : "" ,         confirmPassword : "" ,         gender : null ,         language : [ " english " ] ,         country : " Canada " ,         zipCode : ""       } ,       formErrors : {         name : " FirstName is required " ,         email : null ,         mobile : null ,         password : null ,         confirmPassword : null ,         gender : "" , ...