import React, { Component } from 'react'; import { debounce } from 'lodash'; import { Input } from '@grafana/ui'; export interface Props { onChange: (alignmentPeriod: any) => void; value: string; } export interface State { value: string; } export class AliasBy extends Component { propagateOnChange: (value: any) => void; constructor(props: Props) { super(props); this.propagateOnChange = debounce(this.props.onChange, 500); this.state = { value: '' }; } componentDidMount() { this.setState({ value: this.props.value }); } componentWillReceiveProps(nextProps: Props) { if (nextProps.value !== this.props.value) { this.setState({ value: nextProps.value }); } } onChange = (e: any) => { this.setState({ value: e.target.value }); this.propagateOnChange(e.target.value); }; render() { return ( <>
); } }