score:6
3000 records is a lot to send down to the client in one chunk. It is easier to develop against, but it doesn't scale well and is likely to create a measurable load time. If you're OK with that, and you don't expect your data set to grow, then perhaps the pragmatic approach is to keep it as a big list... but it goes against best practices.
Either way, you likely don't want to show a giant 3k-row list to the user, so the UI will have some sort of pagination mechanism. That might be "next", "previous" pages, or it might be infinite scrolling. Either way, the data abstraction should be considering it as paged data.
Paging API Assuming you decide to make your API support paging, you should use the backend framework's paging capabilities, like the Django Paging API or some other abstraction for your REST API. There are lots of resources out there.
Search The moment you decide to paginate the API, you are committing to handling search (filtering) on the backend as well. The only way you can manage client-side filtering is if the client has access to all the data. Since that isn't the case, you'll need to include a search filter in your data request. Searching and pagination aren't mutually exclusive, so make sure your API supports both at the same time. A common way to handle this would be like this:
http://yoursite.com/api/ingredients?page=5&page_size=100&search=carrot
Client On the React side, you can build your own UI (it is easy to do), or you can use a component which abstracts this for you, like react-js-pagination or react-paginate. The client component shouldn't really care if the API is paged or not. Instead, it just notifies you when to display different records and the rest is up to you.
If you decide to keep everything in one big REST call, then you still need to slice the data out of your array to display. If you paginate your API, then you can keep an instance cache on the client side of the pages you've received. If you don't have the data, make the REST call to get it, and populate an array with the data. That way, if a user goes forwards and then backwards, you aren't re-fetching.
Conclusion I hope this helps a bit. Enjoy :)
Source: stackoverflow.com
Related Query
- how to display large list of data using reactJS as frontend and django rest framework as backend
- How to show first letters of the firstname and lastname of the user in the list instead of image through json data using reactjs
- How to filter data from an array and display it accordingly using ReactJs
- How to send user data and its profile image using POST request from axios api to Django Rest Framework?
- how to send data in GET request header using react and axios to Django rest framework?
- How to display 404 when URL doesn't match any route and when the URL contains /#/ using ReactJS
- How to do POST in FORM Submit using reactjs and pass the object value into REST service?
- How to upload an Excel sheet file using react.js and display data to a table
- How to use Django User Groups and Permissions on a React Frontend with Django Rest Framework
- How to get CSV data using Reactjs and store into state?
- How to display an image in full screen background using reactJS and css?
- How to upload image to aws s3 using react and django rest framework
- How to Upload Images using React, fetch, and Django REST
- How can I Fetch and display Mysql data into ReactJS front end with Node JS as backend?
- How to display xml data using Reactjs
- How to store and populate data into dataGrid or table using reactJs and reactHooks?
- How to implement pagination in a Django and React app without using the REST framework?
- How to fetch data from a custom React hook (API) with onClick and display it in a Div using TypeScript?
- How do I display data from api using react and redux
- Which is the best way to store a list of data in localStorage and display them when searched using a React app
- How to delete data from DB using React, and hitting a rest API that i created using php and mysql?
- How to save Signup form data in database(mysql) using reactjs and nodejs?
- How to list data based on the selected option using react and typescript?
- Fetch and display image in reactjs from django backend using json
- How to dynamically show data in a pie chart using Reactjs and D3js
- How to filter both date and time together from list using reactjs
- How to display three post photo div at the bottom of the page using Reactjs and Css
- How to get data as JSON from this API and display in in my Reactjs app
- Display API data using Axios and a list in React
- How Can I Create Dotted Lines to Display Data in Rows in ReactJS using CSS?
More Query from same tag
- Dynamically wrap text in an anchor tag in Quilljs Error: addRange(): The given range isn't in document
- How to initiate React hook state with foreach loop
- TypeError: Cannot read property 'map' of undefined on React.js
- Delete account with user data
- Image seems to look compressed even though it has enough pixels to look good
- Multiple setState using useState but trigger only once?
- Dynamically link static css in html
- How to inject dotenv variables without REACT_APP prefix in create-react-app?
- When switching the category using the drop down menu the quantity display goes to NaN and cant use increase/decrease function ReactJs
- How to declare type of an array of a dynamic object as react state?
- Error running jest react test, jest not recognized
- alternative to innerRef when using hooks
- Use props outside of render
- React Js custom accordion, open one item at the time
- Rewriting custom route to use render prop instead of component prop in React Router
- Textarea issue in reactJS : A component is changing a controlled input of type undefined to be uncontrolled
- React.js - Each child in a list should have a unique "key" prop
- how can I export react to word document
- Set up webpack to run locally on a custom domain over HTTPS
- Reload variables values in js file
- How to prevent rollup from looking in parent node_modules folder
- setState doesn't get updated the first time in react
- ReactJs clear state after modal close
- Get the ID of a selected Card element and pass it to a modal to select the element
- In one of my React component I stuck with syntax error in my project
- Error: Failed to load parser 'babel-eslint' declared in '.eslintrc': Cannot find module 'babel-eslint' in create-react-app
- how to target the same element im styling in react?
- How to run Front End and Backend together in React.js and Express.js
- Project is not pushed in Heroku
- Uncaught TypeError: Cannot read property 'data' of null in React js