tbleckert / react-select-search

⚡️ Lightweight select component for React
https://react-select-search.vercel.app
MIT License
678 stars 147 forks source link

How to use renderOption? #164

Closed TheGP closed 3 years ago

TheGP commented 3 years ago

There is no source code at https://react-select-search.com/?path=/story/custom--avatar-example

LukeV111 commented 3 years ago

Did you figure this out @TheGP ?

TheGP commented 3 years ago

@LukeV111 Yes: https://react-select.com than u can just search anything and there are a lot of examples on StackOverflow for any question

otox-rz commented 3 years ago

Hi guys, I think you should check on this


function renderFriend(props, option, snapshot, className) {
    const imgStyle = {
        borderRadius: '50%',
        verticalAlign: 'middle',
        marginRight: 10,
    };

    return (
        <button {...props} className={className} type="button">
            <span><img alt="" style={imgStyle} width="32" height="32" src={option.photo} /><span>{option.name}</span></span>
        </button>
    );
}

export const AvatarExample = () => (
    <SelectSearch
        className="select-search select-search--multiple"
        options={friends}
        renderOption={renderFriend}
        multiple
        search
        filterOptions={fuzzySearch}
        placeholder="Search friends"
    />
);

@LukeV111 Yes: https://react-select.com than u can just search anything and there are a lot of examples on StackOverflow for any question

I think this library has very small package size. We can compare it here

https://bundlephobia.com/scan-results?packages=react-select,react-select-search

tbleckert commented 3 years ago

I will improve the storybook as soon as possible, but just a reminder that all code is here on github. All stories/examples can be found here https://github.com/tbleckert/react-select-search/tree/main/stories