Topic: MDBTimePicker in map

marrielle.aboujaoude free asked 4 years ago


Expected behavior updated "MDBTimePicker" once my state is updated

Actual behavior I'm trying to update my time picker once i call an onclick function from outside of MDBTimePicker

Resources (screenshots, code snippets etc.)


Jakub Chmura staff answered 4 years ago


Hi @marrielle.aboujaoude,

As I thought, it's not possible to control this component from outside when it's already rendered. hours and minutes props give you the possibility to pick hours and minutes before initialization. After initialization, we have no influence on the state of the component.

We try to fix this as soon as possible.

Best regards,

Kuba


marrielle.aboujaoude free commented 4 years ago

Thank you because it's a huge bug on my portal and if i want to change it i will need to change all the timepicker


Jakub Chmura staff commented 4 years ago

@marrielle.aboujaoude,

We work on the solution right now, if everything goes fine we publish fix in the next release.

Best regards,

Kuba


Jakub Chmura staff answered 4 years ago


Hi @marrielle.aboujaoude,

Can you send me a sample of your code?

I'll try to do something with this, but it seems to me that's not possible in this component. I'll try to check what's wrong but I'm not able to reproduce this situation without your example.

Best regards,

Kuba


marrielle.aboujaoude free commented 4 years ago

Kindly check the following sample

import React from "react"; import { MDBRow, MDBCol, MDBIcon, MDBTimePicker } from "mdbreact";

class dummySample extends React.Component { constructor() { super(); this.state = { hour: "1", } this.getPickerValueTo = this.getPickerValueTo.bind(this) }

getPickerValueTo = (value) => {
    this.setState({ hour: value });
}

RemoveRow() {
    this.setState({ hour: "12" });
}


render() {

    return (
        <React.Fragment>
            <MDBRow>
                <MDBCol md="1">
                    {this.state.hour}
                </MDBCol>
                <MDBCol md="1">
                    <MDBTimePicker
                        id="totime"
                        name="totime"
                        label="To time"
                        closeOnCancel
                        cancelable
                        hours={this.state.hour}
                        minutes="0"
                        hoursFormat={24}
                        value={this.state.hour}
                        autoSwitch={false}
                        getValue={value => this.getPickerValueTo(value)}
                    />
                </MDBCol>
                <MDBCol md="1">
                    <div onClick={() => this.RemoveRow()}><MDBIcon icon="edit" /></div>
                </MDBCol>

            </MDBRow>

        </React.Fragment >
    );
}

}

export default dummySample



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.21.1
  • Device: laptop
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No