3
<div className="listCheckbox">
            {objects.map((e) => {
              return (
                <div key={e.value}>
                  <FormControlLabel control={<Checkbox />} label={e.label} />
                </div>
              );
            })}
          </div>

//css----------------------------------------------------------------------------------
.listCheckbox {
  max-height: 350px;
  overflow-y: scroll;
}


here objects are a state of type array and contain more than 250 records. how can I render this more efficiently with the same styling

3 Answers 3

2

You can use pagination and limit the records instead of showing it all. And when you try to render more you can just add it to the previous state, This way you won't lose your previous fetched records and it will be more optimized.

Sign up to request clarification or add additional context in comments.

4 Comments

is there any other solution other than pagination???
There is one other way. As you know react takes time when trying to render for the first time. So what you can do is the first time website loads you can fetch the data in useEffect and store it in the state and then you can render it whenever you want and it won't take much time because it is already in your state.
that's what i m doing but still getting issues
You can implement infinite scroll in your component. npmjs.com/package/react-infinite-scroll-component
0

Here are some ways to load large list of data:

Note: I have mentioned some npm libraries within brackets for ease, but these functionalities can be self-implemented as well.

  1. pagination (https://www.npmjs.com/package/react-paginate)
  2. inifinite scroll (https://www.npmjs.com/package/react-infinite-scroll-component)

Also check this blog for more options and explanation.

Comments

0

In case you're not interested in paginating, you should use a virtual list.

You can use react-virtualized, or try building one from scratch

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.