Skip to content

Commit

Permalink
add use client
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-babylonlabs committed Dec 12, 2024
1 parent 70d93cf commit bc80afe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-staking",
"version": "0.3.21",
"version": "0.3.22",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useDebounce } from "@uidotdev/usehooks";
import { useSearchParams } from "next/navigation";
import React, { useEffect, useState } from "react";
Expand All @@ -10,21 +12,12 @@ interface FinalityProviderSearchProps {
export const FinalityProviderSearch: React.FC<FinalityProviderSearchProps> = ({
onSearch,
}) => {
// Get the finality provider from the search params
const searchParams = useSearchParams();
const initialSearchFp = searchParams.get("fp");
const initialSearchTerm = searchParams.get("fp") || "";

const [searchTerm, setSearchTerm] = useState(initialSearchFp || "");
const [searchTerm, setSearchTerm] = useState(initialSearchTerm);
const debouncedSearchTerm = useDebounce(searchTerm, 300);

// Effect for handling initial search
useEffect(() => {
if (initialSearchFp) {
onSearch(initialSearchFp);
}
}, [initialSearchFp, onSearch]);

// Effect for handling subsequent searches
useEffect(() => {
onSearch(debouncedSearchTerm);
}, [debouncedSearchTerm, onSearch]);
Expand Down

0 comments on commit bc80afe

Please sign in to comment.