预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到了:对象

时间:2019-01-28 18:41:49

标签: javascript reactjs jsx

我无法使用所安装的外部模块,并且完全按照文档中的说明进行操作。当我在codeandbox中运行它时,它可以工作,但不能在我自己的开发环境中运行。

这是我的代码:

import React from "react";
import { Treebeard } from "react-treebeard";
import "./custom.css";

const data = {
  name: "root",
  toggled: true,
  children: [
    {
      name: "parent",
      children: [{ name: "child1" }, { name: "child2" }]
    },
    {
      name: "loading parent",
      loading: true,
      children: []
    },
    {
      name: "parent",
      children: [
        {
          name: "nested parent",
          children: [{ name: "nested child 1" }, { name: "nested child 2" }]
        }
      ]
    }
  ]
};

export default class Dialog extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      access_token: ""
    };
  }

  componentWillMount() {
    const access_token = sessionStorage.getItem("access_token")
      ? sessionStorage.getItem("access_token")
      : "";

    this.setState({ access_token });
  }

  onToggle = (node, toggled) => {
    if (this.state.cursor) {
      this.setState({ cursor: { active: false } });
    }
    node.active = true;
    if (node.children) {
      node.toggled = toggled;
    }
    this.setState({ cursor: node });
  };

  render() {
    return <Treebeard data={data} onToggle={this.onToggle} />;
  }
}

这是模块documentation

的链接

1 个答案:

答案 0 :(得分:0)

我已经使用create-react-app和自定义配置进行了测试,但是一切正常。这是我的文件,因此您可以检查开发环境中的不同之处

index.js:

QueryJobConfiguration queryConfig = 
           QueryJobConfiguration.newBuilder(
              "SELECT  PARSE_TIMESTAMP('%b %d %T %Y', CONCAT(time, ' 2018')) MyTimestamp, * EXCEPT(time)"
               + "FROM `myProject:MyDataset.MyTable` ")
              .setUseLegacySql(false)
              .setWriteDisposition(WriteDisposition.WRITE_APPEND)    
              .setDestinationTable(TableId.of(MyOtherDataset, MyOtherTable))
              .build();

package.json:

import React from "react";
import ReactDOM from "react-dom";
import Dialog from "./Dialog";

ReactDOM.render(
  <div>
    <Dialog />
  </div>,
  document.getElementById("app")
);

希望对您有所帮助,如果您提供其他文件,我可以检查您的确切配置。