Skip to content

children #43

Description

@globallyunique

I'm trying to convert the React components of the elastic-search UI framework to use in a svelte app. Several of the components need the children passed as a function to the parent component. I don't want to change the code of the elastic search components. The specific place I'm stuck is the WithSearch component shown below. Can you point me at an example of passing child html components to a React parent or suggest how I pass SearchBox children to WithSearch after I've done: const react = sveltify({ SearchBox, WithSearch, SearchProvider }); instead of using the function the way it's done in this React code? I thought it was with an array of snippets but I can't see how to make that work.

  <**WithSearch** mapContextToProps={({ wasSearched }) => ({ wasSearched })}>
    {({ wasSearched }) => {
      return (
        <div className="App">
          <ErrorBoundary>
            <Layout
              header={
                <**SearchBox**
                  autocompleteMinimumCharacters={3}
                  autocompleteResults={{
                    linkTarget: "_blank",
                    sectionTitle: "Results",
                    titleField: "title",
                    urlField: "url",
                    shouldTrackClickThrough: true
                  }}
                  autocompleteSuggestions={true}
                  debounceLength={0}
                />
              }
              sideContent={
                <div>
                  {wasSearched && <Sorting label={"Sort by"} sortOptions={[]} />}
                  <Facet key={"1"} field={"genre.keyword"} label={"genre"} />
                  <Facet key={"2"} field={"actors.keyword"} label={"actors"} />
                  <Facet key={"3"} field={"directors.keyword"} label={"directors"} />
                  <Facet key={"4"} field={"released"} label={"released"} />
                  <Facet key={"4"} field={"imdbRating"} label={"imdb rating"} />
                </div>
              }
              bodyContent={<Results shouldTrackClickThrough={true} />}
              bodyHeader={
                <React.Fragment>
                  {wasSearched && <PagingInfo />}
                  {wasSearched && <ResultsPerPage />}
                </React.Fragment>
              }
              bodyFooter={<Paging />}
            />
          </ErrorBoundary>
        </div>
      );
    }}
  </WithSearch>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions