How to return redirection("/to some where") and send a state for useActionData at the same time in react router action 6.4v? [closed] - reactjs

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 19 hours ago.
Improve this question
How can i redirect and send email and password data to a component? (structure of this action picture just an example not a real project)

It is hard to say since I don't know the rest of the architecture of your app. In general, you could use React Context or some state manager like Zustand for data that is shared among components. Any data you store there can then be accesed from any component you need that data.
However, you should rethink your apps structure - it is not a good idea to store password anywhere on the frontend or send it accross multiple components.

Related

Should I make all API calls with redux, or should I keep them simply in components? [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 2 years ago.
Improve this question
I am new at using react/redux. I just started working on a react project, but I don't really know which one do I choose when when it comes to making API calls. Should I do all of API calls with redux or are there cases in which I can handle them using components?
Choosing either one has its own merit. If you want the data from API in global state or for any further use you may need to choose to do your calls in redux.
If the interaction is very less and data is not used any further you can opt to do calls in component
Based on the documentation of redux the best practice would be to make you API calls directly in the "actions" of Redux.
You'll be able to find more information on this page: https://redux.js.org/advanced/async-actions
There is also another thread with a really good answer on how to make a proper API call with Redux:
How to properly make REST calls from ReactJS + Redux application?

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!

Why use redux-saga? [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 3 years ago.
Improve this question
I'm recently getting into React.js and learning with a small project.
While studying, I couldn't figure out clearly why I used react-saga or react-thunk.
It is said to process redux state value asynchronously.
But don't we already have async / await?
Shouldn't we call api from a component file using async / await to get a value from the server and store it in the redux store?
I've seen a lot of articles on why to use react-saga, but the question hasn't been answered yet.
Why is there a clear reason to use redux-saga?
Saga deals with more complex async flows. Thunk is the simple tool for async redux actions that is probably enough for 90% of projects. I'm a bit biased here because I think saga is often introduced as a shiny new tool into projects without an actual need. I have yet to see a project where they clearly needed saga (and not just thunk).
To your first question: Yes, we could handle async things in components and use async/await to dispatch actions around api requests, but it's bad design, since you're concerning the React component with things it shouldn't care about. It should contain display logic and be testable with only that.
Getting the data from api responses into the redux store should be handled outside of components because it's simply not a concern of the view rendering abstraction layer in your app.

React props vs redux vs hooks and context api [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 3 years ago.
Improve this question
I need to implement a SPA whose components are going to interact with their local state and are minimum the cases in which these state is going to be nedded by other components. For example: the employee component contains state about an employee that only will be shared with the employee's component children but not from other different component in the site. Until now my idea is to create 'stores' in the parent component (Employee for example) implemented with hooks and Context Api, for achieving max development speed and clarity in code. What do you think?
This is ultimately subjective, and it sounds like you're already leaning towards using the Context API. We made a similar decision on our current project; the amount of data that needs to be shared across the application is quite small, so adding the additional code, dependencies and file structures for Redux did not seem worth it.
But if you are using Context, make sure you have thoroughly plotted out the data flow of all parts of your application, as it's easy to overlook something and run into a situation where getting the data outside of a particular module can become very difficult. Also consider its size. If it's a large application, the benefits of centralizing your state changes for easy testing and debugging are not negligible, and Redux can also help boost performance by automatically memoizing connected components.
Again, this is ultimately opinion-based, but I think it's a concrete and common enough concern with React apps that it bears some discussion, though this might end up being closed.

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