Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Outside props goes here first to be transformed according to Component's logic
- export const useComponentState = props => {
- const { disabled } = props;
- const [loggedIn, setLoggedIn] = React.useState(initialLoggedIn);
- const onLogInButtonClick = () => {
- if (!disabled) {
- setLoggedIn(true);
- }
- };
- const onLogOutButtonClick = () => {
- if (!disabled) {
- setLoggedIn(false);
- }
- };
- const hasLogInButton = !loggedIn;
- const hasLogOutButton = loggedIn;
- return {
- hasLogInButton,
- hasLogOutButton,
- onLogInButtonClick,
- onLogOutButtonClick
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement