I am trying to set up an Admin page that is only accessible to people with a user "level" greater than 2. I am using MobX and React-Router. The problem is likely based on the fact that I don't know how to connect to the MobX store properly. I am importing a function, isAdmin, that is located in a seperate file from routes.js. The function looks like:
export const isAdmin = (nextState, replace) => {
const user = this.context.store.auth.user;
if (user.level < 2 || !user) {
replace({
pathname: '/',
});
}
};
This is loosely based on the final example from the gitHub page for react-router located here.
Thanks for any help!