Skip to content

Commit 4e13706

Browse files
committed
chore(navigation): fix docsearch assumption of browser environment
1 parent 54e7e6b commit 4e13706

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/components/Navigation/Navigation.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Import External Dependencies
22
import React from 'react';
33
import Banner from 'react-banner';
4-
import DocSearch from 'docsearch.js';
54

65
// Import Components
76
import Link from '../Link/Link';
@@ -55,10 +54,14 @@ export default class Navigation extends React.Component {
5554
}
5655

5756
componentDidMount() {
58-
DocSearch({
59-
apiKey: 'fac401d1a5f68bc41f01fb6261661490',
60-
indexName: 'webpack-js-org',
61-
inputSelector: '.navigation-search__input'
62-
});
57+
if ( window.document !== undefined ) {
58+
const DocSearch = require('docsearch.js');
59+
60+
DocSearch({
61+
apiKey: 'fac401d1a5f68bc41f01fb6261661490',
62+
indexName: 'webpack-js-org',
63+
inputSelector: '.navigation-search__input'
64+
});
65+
}
6366
}
6467
}

0 commit comments

Comments
 (0)