This repository has been archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add react-navigation lib. Extract Screen from `App.tsx`. Add navigation beetween `Home.tsx` and `Room.tsx`. Add context for storing global useful data.
- Loading branch information
Showing
10 changed files
with
374 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from 'react'; | ||
import { useState } from 'react'; | ||
|
||
const VideoroomContext = React.createContext< | ||
| { | ||
roomName: string; | ||
setRoomName: React.Dispatch<React.SetStateAction<string>>; | ||
} | ||
| undefined | ||
>(undefined); | ||
|
||
const VideoroomContextProvider = (props) => { | ||
const [roomName, setRoomName] = useState(''); | ||
const value = { roomName, setRoomName }; | ||
|
||
return ( | ||
<VideoroomContext.Provider value={value}> | ||
{props.children} | ||
</VideoroomContext.Provider> | ||
); | ||
}; | ||
|
||
function useVideoroomState() { | ||
const context = React.useContext(VideoroomContext); | ||
if (context === undefined) { | ||
throw new Error('useRoomName must be used within a VideoroomContext'); | ||
} | ||
return context; | ||
} | ||
|
||
export { VideoroomContextProvider, useVideoroomState }; |
Oops, something went wrong.