Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
style(createServer): use this + order mutable variable
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss committed Jan 3, 2019
1 parent b716b14 commit fccab1d
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ const multiIndexSearch = (
const createInstantSearchServer = algoliasearch => {
const InstantSearch = createInstantSearch(algoliasearch, {
Root: 'div',
props: { className: 'ais-InstantSearch__root' },
props: {
className: 'ais-InstantSearch__root',
},
});

let searchParameters = [];
let client;
let client = null;
let indexName = '';
let searchParameters = [];

const findResultsState = function(App, props) {
searchParameters = [];
Expand Down Expand Up @@ -142,34 +144,34 @@ const createInstantSearchServer = algoliasearch => {
resultsState: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
};

constructor(props) {
super();
constructor(...args) {
super(...args);

if (props.searchClient) {
if (props.appId || props.apiKey || props.algoliaClient) {
if (this.props.searchClient) {
if (this.props.appId || this.props.apiKey || this.props.algoliaClient) {
throw new Error(
'react-instantsearch:: `searchClient` cannot be used with `appId`, `apiKey` or `algoliaClient`.'
);
}
}

if (props.algoliaClient) {
if (this.props.algoliaClient) {
// eslint-disable-next-line no-console
console.warn(
'`algoliaClient` option was renamed `searchClient`. Please use this new option before the next major version.'
);
}

client =
props.searchClient ||
props.algoliaClient ||
algoliasearch(props.appId, props.apiKey);
this.props.searchClient ||
this.props.algoliaClient ||
algoliasearch(this.props.appId, this.props.apiKey);

if (typeof client.addAlgoliaAgent === 'function') {
client.addAlgoliaAgent(`react-instantsearch ${version}`);
}

indexName = props.indexName;
indexName = this.props.indexName;
}

onSearchParameters(getWidgetSearchParameters, context, props, searchState) {
Expand Down Expand Up @@ -217,7 +219,10 @@ const createInstantSearchServer = algoliasearch => {
}
}

return { InstantSearch: CreateInstantSearchServer, findResultsState };
return {
InstantSearch: CreateInstantSearchServer,
findResultsState,
};
};

export default createInstantSearchServer;

0 comments on commit fccab1d

Please sign in to comment.