score:0
given that you have a react project that has several modules mainly for:
- user
- blog
- comments
in your action you can do something like this:
// actions/user.js
export const usermessageerror = (payload, message) => {
type: 'user_err_message',
error: {
message,
payload
},
}
you can actually place some error handling case inside of each of the module's reducer like so:
// reducer/user.js
case 'user_err_message':
// you might want to set the request payload and the error message
// to the state in order for you to actually know what's going on
//
// then you could have a toast or a modal in the container or inside
// your component to actually display the actual error message
doing this, you can actually know which module returns an error, what the payload is and actually getting the error message.
you might not need the payload to be returned, but it is all up to you and your preference.
Source: stackoverflow.com
Related Query
- How can I properly handle request errors with React front end?
- How to Handle Post Request in Isomorphic React + React Router Application
- How to handle Audio playing in React & Redux
- Best practice to handle errors in Redux and React
- Redux how to handle errors in reducer
- How to handle side effects when migrating from Redux to React Context API + hooks
- How to use Redux time travel to handle errors
- React Redux: How to handle errors in RTK Queries/Mutation Typescript?
- How to handle asynchronous call in redux react application
- How can I handle errors in state in React JS?
- Redux forms: how to handle errors in form component
- How to handle react errors when using browserify and reactify?
- React - How to handle 403 errors for images/files
- How does React Redux handle successive changes in a loop
- How to cancel Axios request in react redux with hooks?
- How to handle Node.js API errors with React
- How to configure WebPack DevServer to handle the POST request in React JS?
- Handle errors after every request in React apollo
- how handle input errors validation in sub component react hook form
- How to handle request errors in react/redux?
- React Redux Store Layout: How to handle "pending" state of "add item" request?
- How the react router can handle request url like: localhost:9000/blah/#token=albasdf
- How does react router handle url change without causing the browser to request
- How to handle errors in the useEffect's skip in react hooks?
- React redux - how to handle events?
- How handle server errors in React
- How to handle HTTP status errors with React Apollo Client
- How to handle React form errors gracefully
- how to handle subcomponent completion eventsin react / flux / redux
- How to handle POST request from react to django?
More Query from same tag
- 'action' is not defined in Redux
- reactjs -- Solving setState async problem
- Where to put `componentWillMount` initialisation function that modifies state?
- MaterialUI text fade with useEffect and setInterval
- Store fetch data in a variable and use entire json as a prop in a react component
- Undefined Id in ReactJS via Mui Datatable
- react state is not updating when it's value changes
- React Router Dom NavLink and Link not Working
- Button onClick() page redirect in ReactJS
- unable to add a new row into the table current rows
- not able to display data in webpage
- useHistory react-router-dom invalid hook call
- Rerender DOM in React
- How to make a property in react class state with union type
- when new props passed, update functional component states
- Material UI Snackbar + Progress
- Unable to display the data by using useEffect hook inside MaterialTable
- How can I handle width in flexbox with flexDirection column?
- ReactJs - Reactstrap | Jambotron not setting gray background
- If statement into useEffect hooks - ReactJs
- Using Ramda with React to setState
- array.map() does not work as expected to render <li> component in React
- React/Javascript - Render a List of Values Based On Same Object Keys Within an Array of Objects
- How to add image background from props in reactjs
- React/Redux connect does not fire mapStateToProps on store change
- Need to fill in form data from json data . Not showing up
- Menu positioned incorrectly after hovering a MenuItem element (Material-UI)
- Trying to update a single field in a firestore database
- How can I get date,year and month from this created_date: "2021-09-27T06:10:07.972531Z" in react js?
- next.js how to change parent state from child component without triggering a button?