mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
30 lines
894 B
JavaScript
30 lines
894 B
JavaScript
import React from 'react'
|
|
const MovieContext = React.createContext(null)
|
|
|
|
export function MovieProvider(props) {
|
|
const [page, setPage] = React.useState("search");
|
|
const [stream, setStream] = React.useState("");
|
|
const [streamData, setStreamData] = React.useState(null); //{ title: "", slug: "", type: "", episodes: [], seasons: [] })
|
|
|
|
return (
|
|
<MovieContext.Provider value={{
|
|
navigate(str) {
|
|
setPage(str)
|
|
},
|
|
page,
|
|
setStreamUrl: setStream,
|
|
streamUrl: stream,
|
|
streamData,
|
|
setStreamData(d) {
|
|
setStreamData(p => ({...p,...d}))
|
|
},
|
|
resetStreamData() { setStreamData(null) }
|
|
}}>
|
|
{props.children}
|
|
</MovieContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useMovie(props) {
|
|
return React.useContext(MovieContext);
|
|
}
|