-
Notifications
You must be signed in to change notification settings - Fork 0
/
[id].jsx
18 lines (17 loc) · 623 Bytes
/
[id].jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import React, { useEffect } from 'react';
import { setEmail } from '../store/email.reducer';
import { useSelector, useDispatch } from 'react-redux';
/**
* dispatches don't work inside useEffects in dynamic routes or routes with query parameter
* to reproduce:
* navigate to /test => notice the email is set
* navigate to /dsa (or anything else) => notice email is not set
*/
export default function dynamic() {
const dispatch = useDispatch();
const email = useSelector(state => state.email);
useEffect(() => {
dispatch(setEmail('[email protected]'));
}, []);
return <div>Email (Redux State): {email}</div>;
}