Skip to content

Commit

Permalink
feat(docs): select icon from search params
Browse files Browse the repository at this point in the history
  • Loading branch information
junghyeonsu committed Oct 22, 2024
1 parent 89a486e commit a75475a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions docs/components/icongraphy/icon-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ export const IconProvider = ({
iconComponents: Record<string, React.ComponentType>;
}>) => {
const [search, setSearch] = React.useState("");
const searchParams = new URLSearchParams(window.location.search);
const iconName = searchParams.get("icon");
const [selectedIcon, setSelectedIcon] = React.useState<IconData | undefined>(
iconName ? iconData[iconName] : undefined,
);
const [selectedIcon, setSelectedIcon] = React.useState<IconData | undefined>(undefined);

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
React.useEffect(() => {
const searchParams = new URLSearchParams(window.location.search);
const iconName = searchParams.get("icon");
if (iconName) {
setSelectedIcon(iconData[iconName]);
}
}, []);

React.useEffect(() => {
const checkSearchParams = () => {
Expand Down

0 comments on commit a75475a

Please sign in to comment.