mdbootstrap / mdb-react-ui-kit

React 18 & Bootstrap 5 & Material Design 2.0 UI KIT
https://mdbootstrap.com/docs/b5/react/
Other
1.41k stars 264 forks source link

I can't use MDBTimePicker inside MDBModalBody ( Not found warnings ) #78

Closed harshan89 closed 5 years ago

harshan89 commented 5 years ago
<MDBModalBody>
<MDBTimePicker id="timePicker" label="12hrs format" getValue={this.getPickerValue} name="date_time"/>

mdb_react

Kordrad commented 5 years ago

Hi @harshan89 ,

I think you did a typo or something similar. For me, this code works correctly. Check if this code works for you as well.

import React, { Component } from "react";
import {
  MDBContainer,
  MDBBtn,
  MDBModal,
  MDBModalBody,
  MDBModalHeader,
  MDBModalFooter,
  MDBTimePicker
} from "mdbreact";

class ModalPage extends Component {
  state = {
    modal: false
  };

  toggle = () => {
    this.setState({
      modal: !this.state.modal
    });
  };
  getPickerValue = value => {
    console.log(value);
  };
  render() {
    return (
      <MDBContainer>
        <MDBBtn onClick={this.toggle}>Modal</MDBBtn>
        <MDBModal isOpen={this.state.modal} toggle={this.toggle}>
          <MDBModalHeader toggle={this.toggle}>MDBModal title</MDBModalHeader>
          <MDBModalBody>
            <MDBTimePicker
              id="timePicker"
              label="12hrs format"
              getValue={this.getPickerValue}
            />
          </MDBModalBody>
          <MDBModalFooter>
            <MDBBtn color="secondary" onClick={this.toggle}>
              Close
            </MDBBtn>
            <MDBBtn color="primary">Save changes</MDBBtn>
          </MDBModalFooter>
        </MDBModal>
      </MDBContainer>
    );
  }
}

export default ModalPage;