Skip to content

Commit

Permalink
fix: make sure useSession populates session correctly (#1462)
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed Mar 6, 2021
1 parent 0d13040 commit a7e08e2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ const SessionContext = createContext()
*/
export function useSession (session) {
const context = useContext(SessionContext)
const [data, setData] = useState(context?.[0] ?? session)
if (context) return context
return _useSessionHook(session)
}

function _useSessionHook (session) {
const [data, setData] = useState(session)
const [loading, setLoading] = useState(!data)

useEffect(() => {
Expand Down

1 comment on commit a7e08e2

@vercel
Copy link

@vercel vercel bot commented on a7e08e2 Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.