Skip to content

Commit 704a455

Browse files
committed
feat(connectors): connectToggle, forward initial options to render
1 parent 52d13de commit 704a455

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/connectors/toggle/connectToggle.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c
3535
* @property {Object} value the value of the toggle with `name`, `isRefined`, `count`, `onFacetValue` and `offFacetValue`
3636
* @property {function} createURL the function to create a url for the next state
3737
* @property {function} refine updates to the next state
38+
* @property {Object} connectorParams all `CustomToggleWidgetOptions` forwarded to rendering
3839
* @property {InstantSearch} instantSearchInstance the instance of instantsearch on which the widget is attached
3940
*/
4041

@@ -46,11 +47,13 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c
4647
export default function connectToggle(renderFn) {
4748
checkRendering(renderFn, usage);
4849

49-
return ({
50-
attributeName,
51-
label,
52-
values: userValues = {on: true, off: undefined},
53-
}) => {
50+
return options => {
51+
const {
52+
attributeName,
53+
label,
54+
values: userValues = {on: true, off: undefined},
55+
} = options;
56+
5457
if (!attributeName || !label) {
5558
throw new Error(usage);
5659
}
@@ -128,6 +131,7 @@ export default function connectToggle(renderFn) {
128131
createURL: this._createURL,
129132
refine: this.toggleRefinement,
130133
instantSearchInstance,
134+
connectorParams: options,
131135
}, true);
132136
},
133137

@@ -172,6 +176,7 @@ export default function connectToggle(renderFn) {
172176
refine: this.toggleRefinement,
173177
helper,
174178
instantSearchInstance,
179+
connectorParams: options,
175180
}, false);
176181
},
177182
};

0 commit comments

Comments
 (0)