feat(qwik): add component-composition/emit-to-parent (#114)

* fix(qwik): typescript eslint parser

* feat(qwik): add answer button example
This commit is contained in:
Casper Engelmann
2022-08-27 23:40:29 +02:00
committed by GitHub
parent b88dbe0767
commit d7f226dd08
2 changed files with 44 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { component$, PropFunction } from '@builder.io/qwik';
type Props = {
onYes$: PropFunction<() => void>;
onNo$: PropFunction<() => void>;
};
const AnswerButton = component$((props: Props) => {
return (
<>
<button onClick$={props.onYes$}>YES</button>
<button onClick$={props.onNo$}>NO</button>
</>
);
});
export default AnswerButton;

View File

@@ -0,0 +1,26 @@
import { $, component$, useStore } from '@builder.io/qwik';
import AnswerButton from './AnswerButton';
const App = component$(() => {
const store = useStore({
canCome: true,
});
const onAnswerNo = $(() => {
store.canCome = false;
});
const onAnswerYes = $(() => {
store.canCome = true;
});
return (
<>
<p>Can I come ?</p>
<AnswerButton onYes$={onAnswerYes} onNo$={onAnswerNo} />
<p style={{ fontSize: 50 }}>{store.canCome ? '😀' : '😥'}</p>
</>
);
});
export default App;