Use componentWillMount() as a before hook

This commit is contained in:
Rick Carlino 2018-03-19 08:03:35 -05:00
parent 614c39aab0
commit 5470c77a33
2 changed files with 6 additions and 15 deletions

View file

@ -19,15 +19,13 @@ export const attachAppToDom: Callback = () => {
};
export class RootComponent extends React.Component<RootComponentProps, {}> {
render() {
// ==== TEMPORARY HACK. TODO: Add a before hook, if such a thing exists in
// React Router. Or switch routing libs.
componentWillMount() {
const notLoggedIn = !Session.fetchStoredToken();
const restrictedArea = window.location.pathname.includes("/app");
if (notLoggedIn && restrictedArea) {
Session.clear();
}
// ==== END HACK ====
(notLoggedIn && restrictedArea && Session.clear());
}
render() {
return <Provider store={_store}>
<Router history={history}>
{topLevelRoutes}

View file

@ -20,14 +20,7 @@ export function mapStateToProps(props: Everything): Props {
const tools = selectAllTools(props.resources.index);
/** Returns sorted tool slots specific to the tool bay id passed. */
const getToolSlots = (/** uuid: string */) => {
// TODO: three things:
// 1. We don't support multiple bays. Therefore, no need to filter.
// 2. If we add an index to this resource, we don't need to perform
// filtering.
// 3. Once we do support multiple bays, re-add the slot's UUID param.
return toolSlots;
};
const getToolSlots = () => toolSlots;
/** Returns all tools in an <FBSelect /> compatible format. */
const getToolOptions = () => {