fix(socketio): data inconsistence
This commit is contained in:
parent
742fcc9d3c
commit
10b9b4776b
|
|
@ -8,7 +8,7 @@ export const WsContext = createContext({ undefined });
|
|||
|
||||
export const WsProvider = (props) => {
|
||||
const { children } = props;
|
||||
const [users, setUsers] = useState([])
|
||||
const [users, setUsers] = useState(null)
|
||||
const auth = useAuth()
|
||||
const initialize = async () => {
|
||||
// Prevent from calling twice in development mode with React.StrictMode enable
|
||||
|
|
@ -19,7 +19,7 @@ export const WsProvider = (props) => {
|
|||
|
||||
socket.on("users", (data) => {
|
||||
setUsers(data)
|
||||
console.log("data received from users event: ", users)
|
||||
console.log("data received from users event: ", data)
|
||||
})
|
||||
|
||||
socket.emit("newuser",{
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ const Page = () => {
|
|||
}
|
||||
}
|
||||
|
||||
return(ws.users.length > 1 ?
|
||||
return(ws.users ?
|
||||
<Box
|
||||
component="main"
|
||||
sx={{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user