reactivesearch icon indicating copy to clipboard operation
reactivesearch copied to clipboard

Possible to use filters on one screen and display results on another?

Open dres-cifuentes opened this issue 7 years ago • 2 comments

Issue Type: Enhancement Issue

Platform: Native

Description: So I created a Filter Component that imports a bunch of custom created filters so that I can style the UI as much as I want. Originally I had {isFilterDisplayed && <Filters />} in my results screen so that the user can see this component based on local state. For performance purposes, I wanted to to make Filters it's own screen instead.

After moving some components around and connecting filters to react navigation, the UI is working as expected. Unfortunately, the filters being applied aren't being displayed. I figured maybe it's because <ReactiveBase> is being used on different screens and the data isn't being passed around properly.

How can I achieve these results?

So my Results screen looks like:

 <Container>
        <ReactiveBase
          app={ELASTIC_APP_NAME}
          url={ELASTIC_URL}
          credentials={ELASTIC_CREDENTIALS}
          headers={{ 'Content-Type': 'application/json' }}
        >
          <ReactiveList
            style={{ flex: 1 }}
            componentId="results"
            dataField="model"
            size={10}
            showResultStats
            onResultStats={() => null}
            react={{
              and: [
                'filter_type',
              ],
            }}
            onData={res => this.renderRow(res)}
            defaultQuery={() => defaultQuery}
          />
        </ReactiveBase>
      </Container>

and my filters screen looks like:

<View style={styles.vehicleFilterContainer}>
        <Container>
          <ReactiveBase
            app={ELASTIC_APP_NAME}
            url={ELASTIC_URL}
            credentials={ELASTIC_CREDENTIALS}
            headers={{ 'Content-Type': 'application/json' }}
          >
            <Content padder>
              <CustomSingleDropdownList componentId="filter_type" searchType="listingType.keyword" label="Type" />

Screenshots:

Minimal reproduction of the problem with instructions:

Reactivesearch version: x.y.z version 0.12.0

Browser: NATIVE

Anything else:

dres-cifuentes avatar Apr 08 '19 19:04 dres-cifuentes

@dres-cifuentes you can try adding ReactiveBase at root level component which wraps your screens, example App.js.

lakhansamani avatar Apr 09 '19 04:04 lakhansamani

That worked, thanks!

dres-cifuentes avatar Apr 09 '19 19:04 dres-cifuentes