我需要用酶模拟一个 onChange 事件来更新一个不工作的状态组件,我共享组件的代码以便得到帮助。
成分:
import React, { useState } from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
const top100Films = [
{ title: 'The Shawshank Redemption', year: 1994 },
{ title: 'The Godfather', year: 1972 },
{ title: 'The Godfather: Part II', year: 1974 },
];
const Counter = () => {
const [value, setValue] = useState({ title: 'The Godfather', year: 1972 });
const handleAutocomplete = (e, item) => {
setValue(item);
}
return (
<>
{value && ( …Run Code Online (Sandbox Code Playgroud)