|
4 | 4 | * Requires authentication to complete submission process |
5 | 5 | * and contains a series of popups to lead user through the flow. |
6 | 6 | */ |
7 | | -import React, { useCallback, useEffect, useState } from "react"; |
| 7 | +import React, { |
| 8 | + useCallback, |
| 9 | + useEffect, |
| 10 | + useLayoutEffect, |
| 11 | + useState, |
| 12 | +} from "react"; |
8 | 13 | import PT from "prop-types"; |
9 | | -import { useDispatch, useSelector } from "react-redux"; |
| 14 | +import { useDispatch } from "react-redux"; |
10 | 15 | import _ from "lodash"; |
11 | 16 | import { toastr } from "react-redux-toastr"; |
12 | 17 | import { navigate } from "@reach/router"; |
@@ -39,14 +44,20 @@ function SubmitContainer({ |
39 | 44 |
|
40 | 45 | const dispatch = useDispatch(); |
41 | 46 |
|
42 | | - // Set correct state for Completeness tab, and redirect |
43 | | - // to main page if path loaded without any selected roles. |
44 | 47 | useEffect(() => { |
45 | 48 | setCurrentStage(2, stages, setStages); |
46 | 49 | if (!addedRoles || addedRoles.length === 0) { |
47 | 50 | navigate("/taas/myteams/createnewteam"); |
48 | 51 | } |
49 | | - // only needed on initial load, avoids too many re-renders |
| 52 | + // eslint-disable-next-line react-hooks/exhaustive-deps |
| 53 | + }, []); |
| 54 | + |
| 55 | + // redirects user if they enter the page URL directly |
| 56 | + // without adding any roles. |
| 57 | + useLayoutEffect(() => { |
| 58 | + if (!addedRoles || addedRoles.length === 0) { |
| 59 | + navigate("/taas/myteams/createnewteam"); |
| 60 | + } |
50 | 61 | // eslint-disable-next-line react-hooks/exhaustive-deps |
51 | 62 | }, []); |
52 | 63 |
|
|
0 commit comments