Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Friends = () => useList(friends, friend => <li>{friend}</li>)
const Total = () => <small>Total: {useStore(friendsTotal)}</small>
const UserList = () => {
const selectUser = useEvent(selectUserEvent)
return useList(userList, userName => {
const isSelected = useStoreMap({
store: user,
keys: [userName],
fn: (selected, [current]) => selected === current,
})
return (
<>
<br>
<button> selectUser(users[userName])}
disabled={isSelected}>
{userName}
</button>
)
})
const UserList = () => {
const selectUser = useEvent(selectUserEvent)
return useList(userList, userName => {
const isSelected = useStoreMap({
store: user,
keys: [userName],
fn: (selected, [current]) => selected === current,
})
return (
<>
<br>
<button> selectUser(userName)} disabled={isSelected}>
{userName}
</button>
)
})
}
export const App = ({root}) => (
const Friends = () => useList(friends, friend => <li>{friend}</li>)
const Total = () => <small>Total: {useStore(friendsTotal)}</small>