Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better 'Something went wrong.' view #12

Open
AndrewArlenHoneywell opened this issue Jan 17, 2020 · 6 comments
Open

A better 'Something went wrong.' view #12

AndrewArlenHoneywell opened this issue Jan 17, 2020 · 6 comments

Comments

@AndrewArlenHoneywell
Copy link

Hi.
I have a requirement to replace the 'Something went wrong' message with a nicer looking view which is much more complex than a simple string.
How would I go about doing this ?

Should I raise a PR for this change ?

Or should I be forking this project and maintaining my own version ?

@LeonardoGentile
Copy link
Owner

Hello,
please feel free to raise a PR

@AndrewArlenHoneywell
Copy link
Author

Thank you :)
I will get someone on my team to make the relevant changes and raise a PR.

@AndrewArlenHoneywell
Copy link
Author

Hi LeonardoGentile , thank you .

PR has been raised . #13

@Beastrock
Copy link

Beastrock commented Feb 12, 2020

My Armenian friend did something like this:

import {RouteView as BaseRouteView} from "react-mobx-router5";

class ErrorComponent extends React.Component {
    render() {
        return (
            <div>
                My custom component error. Syskius!
            </div>
        )
    }
}

class RouteView extends BaseRouteView {
    render() {
        if (this.state.hasError) {
            return <this.props.errorComponent {...this.props}/>;
        }
        return super.render();

    }
}


class Channels extends React.Component {
    render() {
        const {route} = this.props;
        return (
            <RouteView
                errorComponent={ErrorComponent}
                route={route}
                routes={routesMap}
                routeNodeName={routeNodeName}
            />
        )
    }
}

@Beastrock
Copy link

My Armenian friend decided to go further: redefine render method of RouteView (in app.jsx, for example)

import * as Rmr from "react-mobx-router5";

class ErrorComponent extends React.Component {
    render() {
        return (
            <div>
                My custom component error. Syskius!
            </div>
        )
    }
}

const oldRender = Rmr.RouteView.prototype.render;

Rmr.RouteView.prototype.render = function () {
    if (this.state.hasError) {
        return <ErrorComponent {...this.props}/>;
    }
    return oldRender.apply(this);
};

@christiandamtoft
Copy link

Hi, I saw the PR got merged, is there a release version for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants