I need to get the URL parameters and pass it to context provider. But I ma getting readonly error.
Here is my context file.
import {createContext} from 'react'
export const ParamsContext = createContext();
Here is my setup file:
const Setup = () => {
const [searchParams, setSearchParams] = useSearchParams();
const type = searchParams.get("type");
return (
<ParamsContect.Provider value={type}>
<Library/>
</ParamsContect.Provider>
)
}
export default Setup
I am unable to pass the type in the context. Getting type is read only error. Can anyone help me on this.