mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 09:35:10 +01:00
Make monkeyPatched key specific to component's displayName
This commit is contained in:
parent
4fe10bb887
commit
3374862edf
@ -55,7 +55,7 @@ let EditionContainer = React.createClass({
|
|||||||
const { editionError } = this.state;
|
const { editionError } = this.state;
|
||||||
|
|
||||||
if(editionError && editionError.status === 404) {
|
if(editionError && editionError.status === 404) {
|
||||||
this.throws(new ResourceNotFoundError(getLangText('Ups, the edition you\'re looking for doesn\'t exist.')));
|
this.throws(new ResourceNotFoundError(getLangText('Oops, the edition you\'re looking for doesn\'t exist.')));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ let PieceContainer = React.createClass({
|
|||||||
const { pieceError } = this.state;
|
const { pieceError } = this.state;
|
||||||
|
|
||||||
if(pieceError && pieceError.status === 404) {
|
if(pieceError && pieceError.status === 404) {
|
||||||
this.throws(new ResourceNotFoundError(getLangText('Ups, the piece you\'re looking for doesn\'t exist.')));
|
this.throws(new ResourceNotFoundError(getLangText('Oops, the piece you\'re looking for doesn\'t exist.')));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -14,10 +14,14 @@ export class ResourceNotFoundError extends Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handler(component, err) {
|
handler(component, err) {
|
||||||
if(!component.state._monkeyPatched) {
|
const { displayName } = component.constructor;
|
||||||
|
const monkeyPatchedKey = typeof displayName === 'string' ? `_${displayName}MonkeyPatched`
|
||||||
|
: '_monkeyPatched';
|
||||||
|
|
||||||
|
if(!component.state[monkeyPatchedKey]) {
|
||||||
component.render = () => <ErrorNotFoundPage message={err.message} />;
|
component.render = () => <ErrorNotFoundPage message={err.message} />;
|
||||||
component.setState({
|
component.setState({
|
||||||
_monkeyPatched: true
|
[monkeyPatchedKey]: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user