Skip to content

Commit

Permalink
Refactor context for search modal and page
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekjain23 committed May 17, 2024
1 parent 5e2c99e commit 4f2aa50
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
12 changes: 12 additions & 0 deletions src/theme/Root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable */

import React from 'react';
import { SearchProvider } from '@site/src/utils/SearchContext';

export default function Root({ children }) {
return (
<SearchProvider>
<div>{children}</div>
</SearchProvider>
);
}
21 changes: 21 additions & 0 deletions src/utils/SearchContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable */

import React, { createContext, useState } from 'react';
import { allFacets } from './searchConstant';

export const SearchContext = createContext(null);

export const SearchProvider = ({ children }) => {
const [selectedFacets, setSelectedFacets] = useState(allFacets);

return (
<SearchContext.Provider
value={{
selectedFacets,
setSelectedFacets,
}}
>
{children}
</SearchContext.Provider>
);
};
13 changes: 0 additions & 13 deletions src/utils/useSearch.ts

This file was deleted.

0 comments on commit 4f2aa50

Please sign in to comment.