Browse Source

add navigate

visuddhinanda 3 years ago
parent
commit
3184e6fdee
1 changed files with 12 additions and 2 deletions
  1. 12 2
      dashboard/src/pages/library/dict/show.tsx

+ 12 - 2
dashboard/src/pages/library/dict/show.tsx

@@ -1,10 +1,20 @@
-import { useParams } from "react-router-dom";
+import { useNavigate, useParams } from "react-router-dom";
 
 import Dictionary from "../../../components/dict/Dictionary";
 
 const Widget = () => {
   const { word } = useParams(); //url 参数
-  return <Dictionary word={word} />;
+  const navigate = useNavigate();
+  return (
+    <Dictionary
+      word={word}
+      onSearch={(value: string, isFactor?: boolean) => {
+        if (!isFactor) {
+          navigate("/dict/" + value);
+        }
+      }}
+    />
+  );
 };
 
 export default Widget;