在React js中未定义DateTimeField中的错误

时间:2018-11-21 08:03:35

标签: javascript reactjs

我没有定义DateTimeField上的错误。我正在尝试在react + bootstrap中设置日期选择器。

我从这些URL寻求帮助:


这是我的代码:https://codesandbox.io/s/18941xp52l

import React, { Component } from "react";
import ReactDOM from "react-dom";

import "./styles.css";

class ParentComponent extends Component {
    constructor(props) {
        super(props);
        this.state = {
            date: "1990-06-05",
            format: "YYYY-MM-DD",
            inputFormat: "DD/MM/YYYY",
            mode: "date"
        };
    }

    handleChange = newDate => {
        console.log("newDate", newDate);
        return this.setState({ date: newDate });
    };

    render() {
        const { date, format, mode, inputFormat } = this.state;
        return (
            <DateTimeField
                dateTime={date}
                format={format}
                viewMode={mode}
                inputFormat={inputFormat}
                onChange={this.handleChange}
            />
        );
    }
}

const rootElement = document.getElementById("root");
ReactDOM.render(<ParentComponent />, rootElement);

1 个答案:

答案 0 :(得分:0)

您错过了导入DateTimeField

import DateTimeField from "react-bootstrap-datetimepicker";