How to handle async errors in Flux?

后端 未结 1 1346
滥情空心
滥情空心 2021-02-15 12:41

I\'ve been working with Flux and I\'m really enjoying, but I have one point where I cannot figure what would be the best solution. I made an app that handles a list of orders, a

1条回答
  •  广开言路
    2021-02-15 13:19

    I think option 1 makes sense and is easier to manage as long as the error is only relevant within the scope of that component. I've been using this approach to display errors on form submission for things like user registration, where I know the only place I'll need the error message is directly on the form ("that username is already taken"). I look at this kind of error message as part of the form/component itself, more local state than application state. This sounds a lot like your situation, so I would say this is the better option.

    Option 2 would be more robust to the possibility that the error might become relevant in more than one place in the future. But if you're confident that this is unlikely to happen, I don't see an advantage to the increased complexity compared to option 1.

    0 讨论(0)
提交回复
热议问题