mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-04 11:20:53 +01:00
update filter value on props change
This commit is contained in:
@@ -21,10 +21,10 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React, { ChangeEvent, FormEvent } from "react";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import React, {ChangeEvent, FormEvent} from "react";
|
||||
import {WithTranslation, withTranslation} from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { createAttributesForTesting } from "../devBuild";
|
||||
import {createAttributesForTesting} from "../devBuild";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
filter: (p: string) => void;
|
||||
@@ -59,6 +59,16 @@ class FilterInput extends React.Component<Props, State> {
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
componentDidUpdate = (prevProps: Props) => {
|
||||
const { value } = this.props;
|
||||
const { value: stateValue } = this.state;
|
||||
if (prevProps.value !== value && value !== stateValue) {
|
||||
this.setState({
|
||||
value: value || ""
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { t, testId } = this.props;
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user