Created
April 6, 2020 14:48
-
-
Save DennisDurairaj/8f8bb2def40d0afd1886a8072679fe03 to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
import { useSelector } from 'react-redux'; | |
import { createSelector } from 'reselect'; | |
const selectUsers = state => state.users; | |
const selectNumOfUsers = createSelector( | |
[selectUsers], | |
users => users.length | |
); | |
export const UsersCounter = () => { | |
const NumOfUsers = useSelector(selectNumOfUsers) | |
return <div>{NumOfUsers}</div> | |
}; | |
export const App = () => { | |
return ( | |
<> | |
<span>Number of users:</span> | |
<UsersCounter /> | |
</> | |
) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment