]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/User.js
add helmet
[alttp.git] / resources / js / components / pages / User.js
index 8dfdba45311aa410a0fbd0a858f3278bf4182912..b481112456813a4613a572702bd9b460880969c1 100644 (file)
@@ -1,5 +1,6 @@
 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';
@@ -18,8 +19,9 @@ const User = () => {
 
        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);
@@ -30,6 +32,9 @@ const User = () => {
                                setLoading(false);
                                setUser(null);
                        });
+               return () => {
+                       ctrl.abort();
+               };
        }, [id]);
 
        useEffect(() => {
@@ -59,6 +64,9 @@ const User = () => {
        }
 
        return <ErrorBoundary>
+               <Helmet>
+                       <title>{user.nickname || user.username}</title>
+               </Helmet>
                <Profile user={user} />
        </ErrorBoundary>;
 };