在React Toastify消息中添加材料图标



这是在一个文件夹中定义的代码。我正在字符串中添加材料图标。但它显示错误

React'在使用JSX时必须在范围内

import { toast } from 'react-toastify';
import ErrorIcon from '@material-ui/icons/Error';
const Alert = (type, message) => {
switch (type) {
case 'warning':
return toast.warning(message)
case 'error':
return toast.error(<div><ErrorIcon/> {message}</div>) // look this line
case 'success':
return toast.success(message)
case 'info':
return toast.info(message)
case 'dark':
return toast.dark(message)
default:
return toast(message)
}
}
export default Alert;

正在访问这样的代码。。。

import Alert from '../utils/toster.js';
Alert('error', 'Try Again')

请在使用JSX的文件顶部导入react。

import React from 'react'