Giter Site home page Giter Site logo

Comments (5)

ericclemmons avatar ericclemmons commented on August 14, 2024

My guess is yes, but I'm not 100% sure what you mean. Are you talking about with React Router using willTransitionTo, and aborting if a promise doesn't resolve?

I still need to figure out what to do when promises fail, so maybe this is a good test-case.

A little more detail would be greatly appreciated!

from react-resolver.

srph avatar srph commented on August 14, 2024

Yea, I am referring to willTransitionTo. I don't think there would any deeper details, because it's just the usual hey-an-exception-was-thrown-or-maybe-400-or-500-occured-let's-stop-going-to-this-route thing, like in Angular. I'd like to have them by default with some util or something.

Good work, by the way 👍.

from react-resolver.

srph avatar srph commented on August 14, 2024

In regards to 400, it should be handled by a middleware component (or mixin). The only thing we should be handling, I think, are 500 errors.

from react-resolver.

jesseskinner avatar jesseskinner commented on August 14, 2024

@srph Since react-resolver only deals with promises, not Ajax requests or HTTP errors, it should probably be up to the promises (or whichever library is doing the Ajax calls) to determine whether to resolve or reject based on the HTTP response.

There's still an open question here about error handling, I think, regardless of what is causing the errors.

from react-resolver.

ericclemmons avatar ericclemmons commented on August 14, 2024

I agree.

I think it's highly project-specific, but I definitely see validity in being able to do something like:

Resolver.createContainer(Users, {
  onError: function(error, props, context) { 
    context.router.go(`/error/user?code=404&userId=${props.userId}`)
  resolve: { ... }
});

Alternatively, on the server, if you do `Resolver.renderToString(...).catch()`, you can choose to render an error view instead (effectively a 400 or 500).

To add more fuel to the fire, I was _also_ considering still rendering the view, as long as the `.propTypes` are not `.isRequired`, and let the child component deal with the missing data.  Or, perhaps send an `errors` prop to the view.

Let's continue the discussion in #2, since @jesseskinner foreshadowed this problem in the beginning :)

from react-resolver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.