removed user from loading paramter (it's in global state now)
This commit is contained in:
parent
e9ae50a618
commit
4c51513cfe
1 changed files with 6 additions and 7 deletions
|
|
@ -34,7 +34,7 @@ export default function UserWrapper() {
|
|||
const userAPI = useUserAPI();
|
||||
const useAuth = useAuth0();
|
||||
const hasFetched = useRef(false);
|
||||
const [user, setUser] = useState<pond.User | undefined>(undefined)
|
||||
// const [user, setUser] = useState<pond.User | undefined>(undefined)
|
||||
const [message, setMessage] = useState("Loading user profile...")
|
||||
const [global, setGlobal] = useState<undefined | GlobalState>(undefined)
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ export default function UserWrapper() {
|
|||
setLoading(true)
|
||||
userAPI.getUserWithTeam(user_id).then(resp => {
|
||||
console.log(resp.data.team)
|
||||
if (resp.data.user) setUser(resp.data.user)
|
||||
// if (resp.data.user) setUser(resp.data.user)
|
||||
setGlobal({
|
||||
user: resp.data.user ? User.create(resp.data.user) : User.create(),
|
||||
team: resp.data.team ? Team.create(resp.data.team) : Team.create(),
|
||||
|
|
@ -62,17 +62,16 @@ export default function UserWrapper() {
|
|||
setLoading(false)
|
||||
hasFetched.current = true;
|
||||
})
|
||||
}, [setGlobal, setUser])
|
||||
}, [setGlobal])
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) return;
|
||||
loadUser()
|
||||
}, [loading])
|
||||
|
||||
console.log(user)
|
||||
console.log(loading)
|
||||
console.log(global)
|
||||
if (!user || loading || !global) return (
|
||||
if (loading || !global) return (
|
||||
<LoadingScreen
|
||||
message={message}
|
||||
/>
|
||||
|
|
@ -95,7 +94,7 @@ export default function UserWrapper() {
|
|||
count is {count}
|
||||
</button>
|
||||
<p>
|
||||
Hello, {user.settings?.name}!
|
||||
Hello, {global.user.settings?.name}!
|
||||
</p>
|
||||
</div><p className="read-the-docs">
|
||||
Coming soon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue