This repository was archived by the owner on Mar 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
error handling #56
Copy link
Copy link
Open
Description
I can't find any example for correct error handling.
my code
class Comp1 extends React.Component {
render() {
return (
<div>
<strong>{this.props.foo}</strong>
<Link to="/main">Index</Link>
</div>
);
}
}
var num = 0;
const CompTransmitted = Transmit.createContainer(Comp1, {
initialVariables: {
},
fragments: {
foo: () => {
return new Promise((resolve, reject) => {
//return resolve("bar");
reject(new Error("test error " + (++num)));
});
}
}
});
export default class Comp2 extends React.Component {
onFetch(promise) {
return promise.then(result => {
console.log("ON FETCH RESULT", result);
}, e => {
console.log("ON FETCH ERROR", e);
})
}
render() {
return (
<CompTransmitted onFetch={this.onFetch} />
)
}
}Console log
ON FETCH ERROR Error: test error 1(…)
ON FETCH ERROR Error: test error 2(…)
Test.js?eb08:26 Uncaught (in promise) Error: test error 1(…)
Test.js?eb08:26 Uncaught (in promise) Error: test error 2(…)
- Is there any way to catch an error and display an error message inside the Comp1 component?
- Why
foois resolved twice?
Metadata
Metadata
Assignees
Labels
No labels