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

Commit b766c71

Browse files
refactor(templates): Declare search clients outside of components (#140)
* refactor(templates): Declare the search client outside of the component * style(templates): Reformat search clients
1 parent 1c0819b commit b766c71

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

scripts/__snapshots__/e2e-templates.test.js.snap

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ exports[`Templates Angular InstantSearch File content: src/app/app.component.ts
386386
"import { Component } from '@angular/core';
387387
import * as algoliasearch from 'algoliasearch';
388388
389+
const searchClient = algoliasearch(
390+
'appId',
391+
'apiKey'
392+
);
393+
389394
@Component({
390395
selector: 'app-root',
391396
templateUrl: './app.component.html',
@@ -394,7 +399,7 @@ import * as algoliasearch from 'algoliasearch';
394399
export class AppComponent {
395400
config = {
396401
indexName: 'indexName',
397-
searchClient: algoliasearch('appId', 'apiKey'),
402+
searchClient,
398403
};
399404
}"
400405
`;
@@ -3780,8 +3785,8 @@ import PropTypes from 'prop-types';
37803785
import './App.css';
37813786
37823787
const searchClient = algoliasearch(
3783-
'appId',
3784-
'apiKey'
3788+
'appId',
3789+
'apiKey'
37853790
);
37863791
37873792
class App extends Component {
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { Component } from '@angular/core';
22
import * as algoliasearch from 'algoliasearch';
33

4+
const searchClient = algoliasearch(
5+
'{{appId}}',
6+
'{{apiKey}}'
7+
);
8+
49
@Component({
510
selector: 'app-root',
611
templateUrl: './app.component.html',
@@ -9,6 +14,6 @@ import * as algoliasearch from 'algoliasearch';
914
export class AppComponent {
1015
config = {
1116
indexName: '{{indexName}}',
12-
searchClient: algoliasearch('{{appId}}', '{{apiKey}}'),
17+
searchClient,
1318
};
1419
}

src/templates/React InstantSearch/src/App.js.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import PropTypes from 'prop-types';
1616
import './App.css';
1717

1818
const searchClient = algoliasearch(
19-
'{{appId}}',
20-
'{{apiKey}}'
19+
'{{appId}}',
20+
'{{apiKey}}'
2121
);
2222

2323
class App extends Component {

0 commit comments

Comments
 (0)