--- /dev/null
+import axios from 'axios';
+import React, { useEffect, useState } from 'react';
+import { useParams } from 'react-router-dom';
+
+import ErrorBoundary from '../common/ErrorBoundary';
+import ErrorMessage from '../common/ErrorMessage';
+import Loading from '../common/Loading';
+import NotFound from '../pages/NotFound';
+import Detail from '../techniques/Detail';
+
+const Technique = () => {
+ const params = useParams();
+ const { name } = params;
+
+ const [error, setError] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [technique, setTechnique] = useState(null);
+
+ useEffect(() => {
+ const ctrl = new AbortController();
+ setLoading(true);
+ axios
+ .get(`/api/tech/${name}`, { signal: ctrl.signal })
+ .then(response => {
+ setError(null);
+ setLoading(false);
+ setTechnique(response.data);
+ window.document.title = response.data.title;
+ })
+ .catch(error => {
+ setError(error);
+ setLoading(false);
+ setTechnique(null);
+ });
+ return () => {
+ ctrl.abort();
+ };
+ }, [name]);
+
+ if (loading) {
+ return <Loading />;
+ }
+
+ if (error) {
+ return <ErrorMessage error={error} />;
+ }
+
+ if (!technique) {
+ return <NotFound />;
+ }
+
+ return <ErrorBoundary>
+ <Detail technique={technique} />
+ </ErrorBoundary>;
+};
+
+export default Technique;