import React, { useState } from 'react'; import { storiesOf } from '@storybook/react'; import { Configure, ExperimentalConfigureRelatedItems, Hits, Index, connectPagination, } from 'react-instantsearch-dom'; import { WrapWithHits } from './util'; type Hit = any; const stories = storiesOf('ConfigureRelatedItems', module); stories.add('default', () => ); function RelatedHit({ hit }: { hit: Hit }) { return (
{hit.name}

{hit.name}

); } const PreviousPagination = connectPagination( ({ currentRefinement, refine }) => { return ( ); } ); const NextPagination = connectPagination( ({ currentRefinement, refine, nbPages }) => { return ( ); } ); function ConfigureRelatedItemsExample() { const [referenceHit, setReferenceHit] = useState(null); const ReferenceHit = React.memo<{ hit: Hit }>( ({ hit }) => { return (
setReferenceHit(hit)}> {hit.name}

{hit.name}

); }, (prevProps, nextProps) => { return prevProps.hit.objectID === nextProps.hit.objectID; } ); return ( {referenceHit && (

Related items

)}
); }