【问题标题】:React making a from into componentReact 将 from 变成组件
【发布时间】: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/ 的帮助下编写一个表单

但是现在我不知道如何将这段代码变成一个组件,以便我可以在任何地方使用。

谁能帮我把这段代码做成组件?

我猜这个问题很业余,但我很抱歉。我对反应很陌生。

【问题讨论】:

标签: reactjs redux react-material


【解决方案1】:

我根据您的输入创建了演示:https://codesandbox.io/s/material-ui-2488e 看看 Input.js

【讨论】:

    猜你喜欢
    • 2018-03-28
    • 2020-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-02
    • 1970-01-01
    • 2019-05-20
    • 1970-01-01
    相关资源
    最近更新 更多