【发布时间】:2020-02-16 21:20:25
【问题描述】:
这是我当前的代码:
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Input from '@material-ui/core/Input';
const useStyles = makeStyles(theme => ({
container: {
display: 'flex',
flexWrap: 'wrap',
},
input: {
margin: theme.spacing(1),
},
}));
export default function Inputs() {
const classes = useStyles();
return (
<div className={classes.container}>
<Input
defaultValue="Error"
className={classes.input}
error
inputProps={{
'aria-label': 'description',
}}
/>
</div>
);
}
我在这里学习 react 和非常新,我现在正在 https://material-ui.com/components/text-fields/ 的帮助下编写一个表单
但是现在我不知道如何将这段代码变成一个组件,以便我可以在任何地方使用。
谁能帮我把这段代码做成组件?
我猜这个问题很业余,但我很抱歉。我对反应很陌生。
【问题讨论】:
-
嘿!欢迎来到 StackOverflow!目前的问题似乎是非常开放的。我建议添加一些细节。你期待发生什么?相反会发生什么?有错误吗?请务必阅读 StackOverflow 帮助中心的 How do I ask? 和 How to create a Minimal, Reproducible Example。
标签: reactjs redux react-material