File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed
Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,31 @@ export default () => {
112112 )
113113 ) ;
114114
115+ storiesOf ( 'Breadcrumb' ) . add (
116+ 'default' ,
117+ wrapWithUnmount (
118+ container =>
119+ instantsearch . widgets . breadcrumb ( {
120+ container,
121+ attributes : [
122+ 'hierarchicalCategories.lvl0' ,
123+ 'hierarchicalCategories.lvl1' ,
124+ 'hierarchicalCategories.lvl2' ,
125+ ] ,
126+ rootPath : 'Cameras & Camcorders' ,
127+ } ) ,
128+ {
129+ searchParameters : {
130+ hierarchicalFacetsRefinements : {
131+ 'hierarchicalCategories.lvl0' : [
132+ 'Cameras & Camcorders > Digital Cameras' ,
133+ ] ,
134+ } ,
135+ } ,
136+ }
137+ )
138+ ) ;
139+
115140 storiesOf ( 'Hits' ) . add (
116141 'default' ,
117142 wrapWithUnmount ( container => instantsearch . widgets . hits ( { container } ) )
Original file line number Diff line number Diff line change @@ -50,9 +50,10 @@ Full documentation available at https://community.algolia.com/instantsearch.js/v
5050 * This is commonly used in websites that have a large amount of content organized in a hierarchical manner (usually e-commerce websites).
5151 * @type {Connector }
5252 * @param {function(BreadcrumbRenderingOptions, boolean) } renderFn Rendering function for the custom **Breadcrumb* widget.
53+ * @param {function } unmountFn Unmount function called when the widget is disposed.
5354 * @return {function(CustomBreadcrumbWidgetOptions) } Re-usable widget factory for a custom **Breadcrumb** widget.
5455 */
55- export default function connectBreadcrumb ( renderFn ) {
56+ export default function connectBreadcrumb ( renderFn , unmountFn ) {
5657 checkRendering ( renderFn , usage ) ;
5758 return ( widgetParams = { } ) => {
5859 const { attributes, separator = ' > ' , rootPath = null } = widgetParams ;
@@ -161,6 +162,10 @@ export default function connectBreadcrumb(renderFn) {
161162 false
162163 ) ;
163164 } ,
165+
166+ dispose ( ) {
167+ unmountFn ( ) ;
168+ } ,
164169 } ;
165170 } ;
166171}
Original file line number Diff line number Diff line change 1- import React , { render } from 'preact-compat' ;
1+ import React , { render , unmountComponentAtNode } from 'preact-compat' ;
22import cx from 'classnames' ;
33
44import Breadcrumb from '../../components/Breadcrumb/Breadcrumb' ;
5- import { connectBreadcrumb } from '../../connectors' ;
5+ import connectBreadcrumb from '../../connectors/breadcrumb/connectBreadcrumb ' ;
66import defaultTemplates from './defaultTemplates.js' ;
77
88import {
@@ -183,7 +183,9 @@ export default function breadcrumb({
183183 } ) ;
184184
185185 try {
186- const makeBreadcrumb = connectBreadcrumb ( specializedRenderer ) ;
186+ const makeBreadcrumb = connectBreadcrumb ( specializedRenderer , ( ) =>
187+ unmountComponentAtNode ( containerNode )
188+ ) ;
187189 return makeBreadcrumb ( { attributes, rootPath } ) ;
188190 } catch ( e ) {
189191 throw new Error ( usage ) ;
You can’t perform that action at this time.
0 commit comments