Typescript错误将hintText添加到create-react-app-with-typescript中的TextField

时间:2018-03-19 19:09:55

标签: reactjs typescript material-ui

刚刚下载,安装并运行了create-react-app-with-typescript,我一直在尝试各种组件。当我使用以下行添加带有hintText的TextField时:

import TextField from 'material-ui/TextField';

  <TextField hintText="Hint Text"/><br />
  <Typography variant="display1" gutterBottom>
    Material-UI
  </Typography>

我收到以下错误:

(56,20): Type '{ hintText: string; }' has no properties in common with type 'IntrinsicAttributes & TextFieldProps & { children?: ReactNode; }'.

material-ui版本是1.0.0-beta.38。 打字稿版本是2.7.2。

我尝试了包含@ types / material-ui,但是这产生了许多其他问题(基于阅读其他帖子,预计这个版本的材料-ui)。

想法?

更新:我刚注意到的一件事是,如果我在克隆回购后通过在docs目录中运行npm start来查看文档,那么示例与我在此处找到的有些不同:http://www.material-ui.com/#/components/app-bar

1 个答案:

答案 0 :(得分:0)

您正在使用新版本的Material-UI,hintText道具已由placeholder替换。你应该可以使用:

<TextField placeholder="something" />

有关更多示例,请与她联系:https://material-ui-next.com/demos/text-fields/