Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // Outside props goes here first to be transformed according to Component's logic
  2.  
  3. export const useComponentState = props => {
  4. const { disabled } = props;
  5.  
  6. const [loggedIn, setLoggedIn] = React.useState(initialLoggedIn);
  7.  
  8. const onLogInButtonClick = () => {
  9. if (!disabled) {
  10. setLoggedIn(true);
  11. }
  12. };
  13.  
  14. const onLogOutButtonClick = () => {
  15. if (!disabled) {
  16. setLoggedIn(false);
  17. }
  18. };
  19.  
  20. const hasLogInButton = !loggedIn;
  21.  
  22. const hasLogOutButton = loggedIn;
  23.  
  24. return {
  25. hasLogInButton,
  26. hasLogOutButton,
  27. onLogInButtonClick,
  28. onLogOutButtonClick
  29. };
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement