'How can I prevent users from seeing that pages or links exist?
Due to security, I would like to alter the navmenu and components that are available to react. I am aware I can do things like calling to pull the nav menu, and using naming conventions I can dynamically build routes (I assume, I did something similar in Angular a while back), but I am not sure how to keep pageviews out. I would need to do something like dynamically provide components to React.
The point is, the view and links to said views must not be visible, even in the JavaScript, until I know what your roles within the application are. The option to click an admin link should not even be in the JavaScript unless you are an admin.
Make sense?
I.E. this is unacceptable (pulled from an online example) -
import React from 'react';
import shortid from 'shortid';
import LearnReactView from './views/learnreactView';
import ReactView from './views/reactView';
import JavaScriptView from './views/javascriptView';
import NullView from './views/NullView';
export default function App({ subredditsToShow }) {
const subredditElementList = subredditsToShow.map(
subreddit => {
switch (subreddit) {
case 'reactjs':
return <ReactView key={shortid.generate()} />;
case 'learnreactjs':
return (
<LearnReactView key={shortid.generate()} />
);
case 'javascript':
return (
<JavaScriptView key={shortid.generate()} />
);
default:
return (
<NullView key={shortid.generate()}>
{`"r/${subreddit}" - not implemented`}
</NullView>
);
}
}
);
return <div>{subredditElementList}</div>;
}
In that example, they pull which ones to show from a list, but they have all included in their application. I need to pull a list of components from the server and those are the only ones to ever show up in the JavaScript. I'm not sure what this is referred to in ReactJS, nor if it would support this type of approach. Modular building of the application? The view components, or rather parts of the app that build pages, would need to be pulled from the server, not included in the base application. They could lazyload whatever services they need as well, so that shouldn't be an issue, right?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
