0

I am using ep-mobx-router v0.2.3 in a react typescript project, which is very similar to mobx-router. The documentation page shows that beforeExit is a hook present in the package, but when I am trying to use it, it gives error that its not present in ep-mobx-router. I checked in my "index.d.ts" file in node modules of ep-mobx-router, only onEnter is present there. If I change in the node modules files, and add an entry for beforeEnter there, it works fine.

interface IRoute {
    path: string;
    component?: React.ComponentType<any> | React.ComponentType<any> | React.ReactElement<any> | null;
    async?: Promise<any>;
    onEnter?: LifecyclePropsType;beforeExit?: LifecyclePropsType
    onParamsChange?: LifecyclePropsType;
    childRoutes?: { [key: string]: any };
} 

this interface is present in index.d.ts file in node modules of "ep-mobx-router".

And I want beforeExit also there, like -

interface IRoute {
    path: string;
    component?: React.ComponentType<any> | React.ComponentType<any> | React.ReactElement<any> | null;
    async?: Promise<any>;
    onEnter?: LifecyclePropsType;
    **beforeExit?: LifecyclePropsType**;
    onParamsChange?: LifecyclePropsType;
    childRoutes?: { [key: string]: any };
}

How can I add this extra property to the interface through my react js code?

JSDrogon
  • 31
  • 8
  • That package hasn't been updated in 3 years. You may find the easiest solution is to fork the repo https://github.com/kitze/mobx-router and make any changes you need, then just link it to your npm modules. When I looked at the repo that property exists in the Route class – Isolated May 24 '21 at 13:34
  • yeah, i have tried replacing the ep-mobx-router, with mobx-router, but the code has too many dependencies and I am running into issues because of that, So I just wanted to know if it is possible to add this one line to the interface, so that it would be an easy and time saving solution for me. – JSDrogon May 24 '21 at 13:41
  • https://stackoverflow.com/questions/67633875/beforeexit-hook-not-present-in-ep-mobx-router "Hm, this package is quite weird, it uses mobx-router docs and has mobx-router page as homepage. It also has only 9 downloads this week. Are you sure it is valid package at all?" I agree with this from your other question. You'll have to come up with a hacky solution to make a change to `node_modules`. Whatever you manually change will be overridden, I'd personally see if you can find an alternative to `ep-mobx` as it doesn't seem to receive any updates now – Isolated May 24 '21 at 13:49

0 Answers0