-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: useSelector dynamic debugValue
- Loading branch information
Showing
10 changed files
with
60 additions
and
711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,16 @@ | |
* @author junbao <[email protected]> | ||
*/ | ||
|
||
import { useDispatch, useSelector } from 'amos/react'; | ||
import { memo, useState } from 'react'; | ||
import { hydrate } from 'amos'; | ||
import { useDispatch, useQuery, useSelector } from 'amos/react'; | ||
import { Fragment, memo, useState } from 'react'; | ||
import { signIn } from '../store/user.actions'; | ||
import { userMapBox } from '../store/user.boxes'; | ||
|
||
export const SignIn = memo(() => { | ||
const [input, setInput] = useState(''); | ||
const dispatch = useDispatch(); | ||
useQuery(hydrate([userMapBox])); | ||
const userMap = useSelector(userMapBox); | ||
return ( | ||
<div className="sign-in"> | ||
|
@@ -25,12 +27,10 @@ export const SignIn = memo(() => { | |
<br /> | ||
<span>Users: </span> | ||
{Array.from(userMap.values(), (u) => ( | ||
<> | ||
<button key={u.id} onClick={() => dispatch(signIn(u.name))}> | ||
{u.name} | ||
</button> | ||
<Fragment key={u.id}> | ||
<button onClick={() => dispatch(signIn(u.name))}>{u.name}</button> | ||
| ||
</> | ||
</Fragment> | ||
))} | ||
</div> | ||
)} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.