Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(js): Convert AppRoot to a functional component #28925

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions static/app/views/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from 'react';
import {useEffect} from 'react';
import {browserHistory, RouteComponentProps} from 'react-router';

import {DEFAULT_APP_ROUTE} from 'app/constants';
Expand All @@ -21,20 +21,19 @@ type Props = {
* TODO: There might be an edge case where user does not have `lastOrganization` set,
* in which case we should load their list of organizations and make a decision
*/
class AppRoot extends Component<Props> {
componentDidMount() {
const {config} = this.props;

if (config.lastOrganization) {
browserHistory.replace(
replaceRouterParams(DEFAULT_APP_ROUTE, {orgSlug: config.lastOrganization})
);
function AppRoot({config}: Props) {
useEffect(() => {
if (!config.lastOrganization) {
return;
}
}

render() {
return null;
}
const orgSlug = config.lastOrganization;
const url = replaceRouterParams(DEFAULT_APP_ROUTE, {orgSlug});

browserHistory.replace(url);
}, []);

return null;
}

export default withConfig(AppRoot);