Fetching data from database(React.js) [closed] - reactjs

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
In my app, some components use different categories of data(clothes, shoes etc.).
Is it better to fetch data from database once and put it to storage? Or i should let every single component fetch data directly from database?

You're looking for Redux (an implementation of flux). Redux gives you a global state to work with that you can connect components into. You can make an api call in one component, and if added to state (using actions + reducers), you can update data from a completely different component. They don't even need a parent/child relationship in your component hierarchy.
So yes, you're looking for "storage", in the form of a global state for your entire React app.

Related

What is the most effective way of State Management in Enterprise level React Application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 months ago.
Improve this question
I am totally confused about how to manage the application level state in React.
I have an enterprise-level application frontend that has some data that is used across application.
Should I use Redux or react hooks or my own JavaScript code that manages the state?
If you are going to need to share the state across a lot of components then you could use either Redux or useContext hook (more Simpler and easy to understand than Redux).
If you have a lot of data (configurations etc) to be shared by multiple components on different hierarchy levels then I will recommend you to use redux-toolkit

Handle large number of rows in react native [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
TechStack:
React Native
Redux
One of my screen in react native app has list of people registered in the application. It can have thousands of rows. I am planning to have a infinite scroll. What i am concerned is how to keep those rows.
Shall i use redux to keep the rows in the state or shall i store them in a simple variable that keeps on updating.
It depends on what kinda features your list has.
if your list is only for display, simply store your list inside useState.
if your list items have a very nested component structure until
using data to display,
redux can help you to prevent prop drilling.
if your data can change from many places and you are worried about losing tracking of data
redux can help you.

What is the need of redux in react? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
When we have component to write all logic then why we use redux. As we can separate template and styling from component
In the simplest words, you need redux for very complex state management in a large project. When you work on a large production level project, there are several components and states to worry about, and passing components between states becomes a mess. You could use context but in many cases you may need to move state up by 1 or more components to be able to use it effectively. This kind of problem is what redux aims to solve, and you will not be able to appreciate unless you work on a large project where components depend on other component's states.

How to listen for changes with react and firebase? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have two separate projects one is a react application and the other one is for my firestore API that I have functions setup. I call these functions in my react application. I have them separated since the firebase package is very large.
I am looking to figure out how to have my data in real time. I know how to setup snapshots in my functions. So I am wondering if I could setup a function that pings my react application(that could be listener for) that something has updated.
Check out https://github.com/tylermcginnis/re-base - it allows you to persist your data in the React State mirroring any changes that are made in your database. It was made specifically for Firebase + React.js.
There are endpoints (amongst many others) namely syncState which is a two-way bind to state and bindToState which is a one-way bind to state.
Hope this helps!

How to populate list from api and pass data to new page when item is clicked?(react native) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am very new to react native and am trying to populate a list with an image and a heading using a fetch() call from a web service . I need this list to populate as soon as the page is displayed. I am struggling to find the right method/event to put my logic in .
Also i have a separate page to see the detailed article. Is there a clean way to pass on information to this page so i can avoid making another api call or a messy global variable.
You should read up on Redux. It might seem a bit hard to understand while reading but the implementation is pretty simple and straight forward.
Also, take a look at this article by Dan Abramov, the main contributor of Redux, talking about Presentational and Container components.

Resources