Created
June 26, 2021 11:26
-
-
Save Cerwyn/666a083b43100772c125b308c2d73c1f to your computer and use it in GitHub Desktop.
preact
This file contains hidden or 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 { FunctionalComponent } from 'preact'; | |
import { html } from 'htm/preact'; | |
import { useEffect, useContext } from "preact/hooks"; | |
import style from './style.scss'; | |
import { StoreContext } from '../../services/StoreContext'; | |
import { useObserver } from 'mobx-react-lite'; | |
// Note: `user` comes from the URL, courtesy of our router | |
const Profile: FunctionalComponent = (props: any) => { | |
const { user } = props; | |
const store: any = useContext(StoreContext); | |
const { counter } = store; | |
useEffect(() => { | |
// | |
}, []); | |
return useObserver(() => { | |
return html` | |
<div class=${style.profile}> | |
<h1>Profile: ${user}</h1> | |
<p>This is the user profile for a user named ${user}.</p> | |
<p> | |
<button onClick=${() => store.setCounter(1)}>Click Me</button> | |
${' '} | |
Clicked ${store.getCounter()} times. | |
</p> | |
</div> | |
`; | |
}) | |
} | |
export default Profile; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment