JavaScript React/Flux - error propagation from action to store/component react flux error handling,react-native-router-flux error

This is a question about error propagation from react/flux actions into the store and then back to the component, the error is not validation, rather its an api call failure when trying to update the state of the store.

Here is a pretty simple example:

Component:

CityList.jsx
    list of cities is held in a field thats bound to store data field, - This loops over these and writes list of City.jsx:

City.jsx
    Populates the city data to the user, including a toggle button to say whether they have visited or not, e.g:

    name: {this.state.city.name}
    country: {this.state.city.country}
    visited: {this.state.city.visited}

Toggling the 'visited' button fires a 'toggleVisited' action with that city object:

Actions:
    CityActions.js
        toggleVisited(city)
        Takes a city object, makes a request to the api to update the 'visited' value and pushes result to store

Store:
    CityStore.js
        onToggleVisited(city)
        Receives city object from the action and updates the relevant item in its cities array with new value

Now what happens when the api called in the CityActions returns an error? How do I map that to the correct component to show the appropriate error messages (red border, error text etc) to indicate that the update failed?

My initial thought was to set an error field on the city object after the api call in the action, then set it back in the store looking something like this:

{
    name: '',
    country: '',
    visited: '',
    error: true
}

(error could be an object) Then the component would re-render the city and

so then the component could read the error field and show the relevant error messages when its rendered.

So:

  • Is there a better way to handle these errors?
  • If I wanted to show a global error at the top of the page, theres no way to know without looping through the data to check for at least one instance of {error: true} and then render the error - this is not ideal.
  • Is there any way to map errors to components?
Answer:1

In javascript (jquery), I'm retrieving a list of elements that start with "#error-". This works correctly. The problem I have is that I can't assign a value to elements of the array while looping ...

In javascript (jquery), I'm retrieving a list of elements that start with "#error-". This works correctly. The problem I have is that I can't assign a value to elements of the array while looping ...

  1. iterate through list python
  2. iterate through list java
  3. iterate through list c++
  4. iterate through list javascript
  5. iterate through list of dictionaries python
  6. iterate through list of tuples python
  7. iterate through list bash
  8. iterate through list python with index
  9. iterate through list backwards python
  10. iterate through list scala
  11. iterate through list of strings python
  12. iterate through list ocaml
  13. iterate through list r
  14. iterate through list golang
  15. iterate through list haskell
  16. iterate through list matlab
  17. iterate through list kotlin
  18. iterate through list of objects python
  19. iterate through list groovy
  20. iterate through list java 8

Is it possible to get the execution time of a loop with an asynchronous function inside of the loop? The following would work for synchronous functions, but not asynchronous: var amount = 100; var ...

Is it possible to get the execution time of a loop with an asynchronous function inside of the loop? The following would work for synchronous functions, but not asynchronous: var amount = 100; var ...

  1. timing loops in vlsi
  2. timing loops in synthesis
  3. timing loops in javascript
  4. timing loop in python
  5. timing loop in java
  6. labview timed loop
  7. timing loop in vhdl
  8. timing for loops
  9. timing for loop c++
  10. timing for loop arduino

I am trying to create a simple a TODO list app in ReactJS. My basics of React are not very clear so I am stuck here. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title&...

I am trying to create a simple a TODO list app in ReactJS. My basics of React are not very clear so I am stuck here. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title&...

  1. uncaught typeerror cannot read property
  2. uncaught typeerror cannot read property 'addeventlistener' of null
  3. uncaught typeerror cannot read property 'length' of undefined
  4. uncaught typeerror cannot read property 'style' of null
  5. uncaught typeerror cannot read property 'fn' of undefined
  6. uncaught typeerror cannot read property 'type' of undefined
  7. uncaught typeerror cannot read property 'value' of null
  8. uncaught typeerror cannot read property 'appendchild' of null
  9. uncaught typeerror cannot read property '0' of undefined
  10. uncaught typeerror cannot read property 'style' of undefined
  11. uncaught typeerror cannot read property 'mdata' of undefined
  12. uncaught typeerror cannot read property 'setstate' of undefined
  13. uncaught typeerror cannot read property 'call' of undefined
  14. uncaught typeerror cannot read property 'top' of undefined
  15. uncaught typeerror cannot read property 'replace' of undefined
  16. uncaught typeerror cannot read property 'map' of undefined
  17. uncaught typeerror cannot read property of null
  18. uncaught typeerror cannot call a class as a function

I have two forms that have to use the same IDs, etc. however, one is specifically for mobile viewing and the other for everything else. I am using media queries and display: none to show/hide each, ...

I have two forms that have to use the same IDs, etc. however, one is specifically for mobile viewing and the other for everything else. I am using media queries and display: none to show/hide each, ...

  1. css completely remove element
  2. jquery completely remove element from dom
  3. how to completely remove element 3d
  4. how to completely remove an element from an array