import axios from 'axios';
import React, { useEffect, useState } from 'react';
+import { Helmet } from 'react-helmet';
import { useParams } from 'react-router-dom';
import ErrorBoundary from '../common/ErrorBoundary';
useEffect(() => {
setLoading(true);
+ const ctrl = new AbortController();
axios
- .get(`/api/users/${id}`)
+ .get(`/api/users/${id}`, { signal: ctrl.signal })
.then(response => {
setError(null);
setLoading(false);
setLoading(false);
setUser(null);
});
+ return () => {
+ ctrl.abort();
+ };
}, [id]);
useEffect(() => {
}
return <ErrorBoundary>
+ <Helmet>
+ <title>{user.nickname || user.username}</title>
+ </Helmet>
<Profile user={user} />
</ErrorBoundary>;
};