]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16296 Replace React legacy lifecycle methods in Users App
authorMathieu Suen <mathieu.suen@sonarsource.com>
Mon, 25 Apr 2022 07:21:19 +0000 (09:21 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 25 Apr 2022 20:02:45 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/users/UsersApp.tsx

index a7e2877cec74c994783edf2db53e2ffb198d8a4d..5ddcdda1afe4ded84615a8d4eea31dead7aac4cb 100644 (file)
@@ -55,9 +55,9 @@ export class UsersApp extends React.PureComponent<Props, State> {
     this.fetchUsers();
   }
 
-  componentWillReceiveProps(nextProps: Props) {
-    if (nextProps.location.query.search !== this.props.location.query.search) {
-      this.fetchUsers(nextProps);
+  componentDidUpdate(prevProps: Props) {
+    if (prevProps.location.query.search !== this.props.location.query.search) {
+      this.fetchUsers();
     }
   }
 
@@ -78,7 +78,8 @@ export class UsersApp extends React.PureComponent<Props, State> {
       }
     });
 
-  fetchUsers = ({ location } = this.props) => {
+  fetchUsers = () => {
+    const { location } = this.props;
     this.setState({ loading: true });
     searchUsers({ q: parseQuery(location.query).search }).then(({ paging, users }) => {
       if (this.mounted) {