materialui autocomplete sort code example

Example 1: material ui autocomple how make first option is selected as default

 option.label}
    defaultValue={Options.find(v => v.label[0])} 
    renderInput={params => (
      
    )}
  />

Example 2: how to set dynamic autocomplete with material ui

import React, { useState } from 'react';
using useState:

   const [val,setVal]=useState({})
changin value on click of button

  const handleClick = () => {
    setVal(top100Films[0]);//you pass any value from the array of top100Films
   // set value in TextField from dropdown list
 };
and pass this value to component in render

  option.title}
    style={{ width: 300 }}
    renderInput={params => (
      
    )}
  />

Tags:

Misc Example