LeonardoGentile / react-mobx-router5

React components for routing solution using router5 and mobx
MIT License
59 stars 5 forks source link

A better 'Something went wrong.' view #12

Open AndrewArlenHoneywell opened 4 years ago

AndrewArlenHoneywell commented 4 years ago

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 commented 4 years ago

Hello, please feel free to raise a PR

AndrewArlenHoneywell commented 4 years ago

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

AndrewArlenHoneywell commented 4 years ago

Hi LeonardoGentile , thank you .

PR has been raised . https://github.com/LeonardoGentile/react-mobx-router5/pull/13

Beastrock commented 4 years ago

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 commented 4 years ago

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 commented 1 year ago

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