Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search: Why does using resultRenderer my data to have title and key fields? #3464

Closed
kayqq opened this issue Feb 26, 2019 · 2 comments
Closed

Comments

@kayqq
Copy link

kayqq commented Feb 26, 2019

I am trying to use a custom renderer in my Search component. I want to re-use my uid and username as key without having to reformat my results to include title and key fields.

Is there a way to pass my uid as a key prop from my custom resultRenderer to <SearchResult /> inside of <Search />?
Why does using resultRenderer require a title prop? Is there a way to override this or a way around it that doesnt require altering the data objects in the results array?

Custom renderer:

const resultRenderer = ({ uid, username }) => (
    <span key={uid} title={username}>
        {username}
    </span>
);

My Search component's settings

<Search
    onResultSelect={onResultSelect}
    onSearchChange={onSearchChange}
    results={results}
    resultRenderer={resultRenderer}
    value={searchTerm}
/>

Example results array:

results = [
    { 
        uid: "4735ce9132924caf8a5b17789b40f79c",
        username: "jimmy"
    }, 
    { 
        uid: "971029de22304eb38b22da5fc7757354",
        username: "bobby"
    }
]
@welcome
Copy link

welcome bot commented Feb 26, 2019

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@layershifter
Copy link
Member

Duplicate #1141.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants