小编Fab*_*ian的帖子

流程给出了一个错误“无法为此分配[值]。[属性],因为[类]中缺少属性[属性]”

这有效:

// @flow
import React, {Component} from 'react';


type Props = {};

class Delete extends Component<Props> {
  targetElement: null | winndow.HTMLInputElement;

  constructor(props: Props) {
    super(props);

    this.targetElement = null; // initialize to null
  }

  handleClick = (e: SyntheticEvent<> & {target: window.HTMLInputElement}) => {
    this.targetElement = (e.target: window.HTMLInputElement).value;
  };

  render() {
    return (
      <input onClick={this.handleClick} value="hello" />
    );
  }
}

export default Delete;
Run Code Online (Sandbox Code Playgroud)

但这不是:

...
handleClick = (e: SyntheticEvent<> & {target: window.HTMLInputElement}) => {
    this.targetElement = e.target.value;
  };
...
Run Code Online (Sandbox Code Playgroud)

错误消息是:Cannot get …

reactjs flowtype

5
推荐指数
1
解决办法
1689
查看次数

如何从组件中访问主题面板?

我正在尝试构建一个呈现div显示错误的组件。

function ErrorDiv(props) {
  return (
    <Card>
      <Typography>{props.message}</Typography>
    </Card>
  );
}
Run Code Online (Sandbox Code Playgroud)

我想设置<Card>背景颜色为palette.error.main<Typography>字体颜色为白色的样式。

但是,我不确定如何访问主题颜色。是否有palette暴露的变量?或者我应该在我的主题创建模块中将单个颜色导出为字符串,然后导入颜色以供此处使用?

material-ui

5
推荐指数
2
解决办法
4876
查看次数

标签 统计

flowtype ×1

material-ui ×1

reactjs ×1