生成页面时,未定义数据



我不知道为什么当我启动服务器时,错误模式说'数据未定义'。但是我定义了数据内容。

export default class App extends Component {
data = [
{
key: "john",
value: "John Doe",
},
{
key: "jane",
value: "Jane Doe",
},
{
key: "mary",
value: "Mary Phillips",
},
{
key: "robert",
value: "Robert",
},
{
key: "karius",
value: "Karius",
},
];
render() {
return (
<ReactSearchBox
placeholder="Search for John, Jane or Mary"
data={data}
onSelect={(record) => console.log(record)}
onFocus={() => {
console.log("This function is called when is focussed");
}}
onChange={(value) => console.log(value)}
fuseConfigs={{
threshold: 0.05,
}}
value="John"
/>
);
}
}

需要在data前添加const

最新更新