We’re going to be referring a lot to the views type, found here.
Determine where the user is coming from
In our example, we will show a different signup/login experience to users coming from a specific URL. We will use theuseLocation
hook from react-router-dom
to get the current URL.
useState
hook to create a state variable called source
and a setter function called setSource
. We are then using the useEffect
hook to set the source to the current location.
Declare the views
Views are passed in via the overrides key on the settings prop of DynamicContextProvider The view object itself is of a specific type and you can review the type on the reference. In our case, we want two different views, one for Facebook and one for Web3. We will use thefacebook
and web3
views.
Setting types to state
We want somewhere to store our view overrides. We will use theuseState
hook to create a state variable called viewOverrides
and a setter function called setViewOverrides
.
Setting the view overrides
We will use theuseEffect
hook to set the view overrides to the correct view based on the source.
Adding to the DynamicContextProvider
We can now pass the viewOverrides to theDynamicContextProvider
.