Skip to content

Commit

Permalink
useref
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Dec 2, 2019
1 parent 1ec2d91 commit 998fc89
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React, {useState, useRef, useCallback} from 'react';
import React, {useRef, useCallback} from 'react';
import classnames from 'classnames';

import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
Expand All @@ -16,23 +16,23 @@ const loadJS = () => import('docsearch.js');
let loadedJs = false;

const Search = props => {
const [initialized, setInitialized] = useState(false);
const initialized = useRef(false);
const searchBarRef = useRef(null);
const {siteConfig = {}} = useDocusaurusContext();
const {
themeConfig: {algolia},
} = siteConfig;

const initAlgolia = () => {
if (!initialized) {
if (!initialized.current) {
window.docsearch({
appId: algolia.appId,
apiKey: algolia.apiKey,
indexName: algolia.indexName,
inputSelector: '#search_input_react',
algoliaOptions: algolia.algoliaOptions,
});
setInitialized(true);
initialized.current = true;
}
};

Expand Down

0 comments on commit 998fc89

Please sign in to comment.