JedWatson / JedWatson/react-select

how to apply extra element at the top of all list

Open
#5,647 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

I used custom component for options.

const Option = (props) => {

    return (
       
           <components.Option {...props}>
            <input
                type="checkbox"
                checked={props.isSelected}
                onChange={() => null}
            />{" "}
            <label>{props.label}</label>
           </components.Option>
    );
};


so here's the code I want to wrap all option in single element, to do so i did below

    const Option = (props) => {

    return (
        <InfiniteScroll
        // className="row"
        dataLength={virtualTours.tour}
        next={fetchMoreDataForInfiniteVRtour}
        hasMore={virtualTours.setHasMoreVirtualTour}
        loader={virtualTours.tour.length > 25 ?<h4>Loading...</h4>: ""}
        endMessage={
            <p style={{ textAlign: "center" }}>
            </p>
        } 
        scrollThreshold= "300px"
        scrollableTarget= "react-select-2-listbox"
        >
            <components.Option {...props}>
            <input
                type="checkbox"
                checked={props.isSelected}
                onChange={() => null}
            />{" "}
            <label>{props.label}</label>
            </components.Option>
        </InfiniteScroll>
    );
};

but it wrapped each option with `InfiniteScroll`, but i don't want wrapped each `option`

I want like this

 <InfiniteScroll
        // className="row"
        dataLength={virtualTours.tour}
        next={fetchMoreDataForInfiniteVRtour}
        hasMore={virtualTours.setHasMoreVirtualTour}
        loader={virtualTours.tour.length > 25 ?<h4>Loading...</h4>: ""}
        endMessage={
            <p style={{ textAlign: "center" }}>
            </p>
        } 
        scrollThreshold= "300px"
        scrollableTarget= "react-select-2-listbox"
        >
            <option>1</option>
            <option>2</option>
            <option>3</option>
            <option>4</option>
            <option>5</option>
            <option>6</option>
    </InfiniteScroll>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom Option example in the issue and review react-select's component customization documentation and list-rendering entry points. Determine whether a list-level wrapper can be supported instead of wrapping each option; done means documenting or specifying the supported approach, with any relevant example or test identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.