You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
894 B
30 lines
894 B
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); |
|
}
|
|
|