Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ranges parameter not updating #68

Open
Zhu-K opened this issue Mar 20, 2022 · 0 comments
Open

Ranges parameter not updating #68

Zhu-K opened this issue Mar 20, 2022 · 0 comments

Comments

@Zhu-K
Copy link

Zhu-K commented Mar 20, 2022

The ranges parameter doesn't seem to update after the first render. For example, here I have an option to select the range in the past 5 minutes, however this range is stuck on between 5 minutes before page load and the load time, instead of current time, despite now=new Date(); Please advise on how to update ranges.

class TimeContainer extends Component {
  render() {
    let startTime = moment(new Date(this.props.startTime));
    let endTime = moment(new Date(this.props.endTime));
    let value = `${startTime.format("MM/DD/YYYY HH:mm")} - ${endTime.format(
      "MM/DD/YYYY HH:mm"
    )}`;

    let now = new Date();
    let ranges = {
      "5 Minutes": [moment(now).subtract(5, "minutes"), moment(now)],
    };

    let local = {
      format: "MM-DD-YYYY HH:mm",
      sundayFirst: false,
    };

    return (
      <div>
        <DateTimeRangeContainer
          ranges={ranges}
          start={startTime}
          end={endTime}
          local={local}
          maxDate={moment(now)}
          applyCallback={this.props.applyCallback}
          pastSearchFriendly={true}
        >
          <Form.Control
            id={this.props.id}
            type="text"
            label="Text"
            readOnly
            placeholder="Date Time Picker"
            value={value"}
          />
        </DateTimeRangeContainer>
      </div>
    );
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant