Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mui date picker

const DatePickerComponent = props => {
  const { name, label, control, require, defaultValue = new Date(), errors, format = 'dd/MM/yyyy' } = props

  return (
    <FormControl fullWidth sx={{ mb: 4 }}>
      <LocalizationProvider dateAdapter={AdapterDateFns}>
        <Controller
          name={name}
          control={control}
          defaultValue={defaultValue}
          rules={{ required: !!require }}
          error
          render={({ field: { value, onChange } }) => (
            <DatePicker
              name={name}
              label={label}
              inputFormat={format}
              error={Boolean(errors[name])}
              value={value}
              onChange={onChange}
              renderInput={({error, ...params}) => <TextField {...params} error={error || errors[name] ? true : false} />}
            />
          )}
        />
      </LocalizationProvider>
      {errors[name] && <FormHelperText sx={{ color: 'error.main' }}>{errors[name].message}</FormHelperText>}
    </FormControl>
  )
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: nan in js 
Javascript :: JavaScript Destructuring - From ES6 
Javascript :: remove string from outside array javascript 
Javascript :: alert library css and js 
Javascript :: react native border radius not working ios 
Javascript :: the filter array 
Javascript :: javascript callbacks anonymous function 
Javascript :: function js 
Javascript :: check if the collection exists in mongodb database mongoose 
Javascript :: sequelize transaction 
Javascript :: react table with styles 
Javascript :: mongoose node js 
Javascript :: call local function javascript 
Javascript :: gps nodejs 
Javascript :: mongodb mongoose update delete key 
Javascript :: es6 spread assign nested object 
Javascript :: base64 in js 
Javascript :: js console log 
Javascript :: react native flatlist flex direction 
Javascript :: jq break line 
Javascript :: how to run a react app 
Javascript :: lodash isNil 
Javascript :: nodejs: router by use express and path package 
Javascript :: npm fund 
Javascript :: js update query string without refresh 
Javascript :: javascript image preview before upload 
Javascript :: how to build and deploy a react app to github pages 
Javascript :: how to control where the text cursor on div 
Javascript :: byte array to json 
Javascript :: prototype, __proto__ 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =