simplified example

master
Atul R 5 years ago
parent 723114261d
commit 491eb65025
  1. 18
      src/index.tsx

@ -1,19 +1,17 @@
import { Renderer, View, Text, Button, Window } from "@nodegui/react-desktop"; import { Renderer, View, Text, Button, Window } from "@nodegui/react-desktop";
import React, { useState, useMemo } from "react"; import React, { useState } from "react";
import { QPushButtonEvents } from "@nodegui/nodegui";
const App = () => { const App = () => {
const [time, setTime] = useState(`${new Date()}`); const [time, setTime] = useState(`${new Date()}`);
const buttonEventHandlers = useMemo(
() => ({
[QPushButtonEvents.clicked]: () => setTime(`${new Date()}`)
}),
[]
);
return ( return (
<Window styleSheet={styleSheet}> <Window minSize={{ width: 500, height: 200 }} styleSheet={styleSheet}>
<View id="container"> <View id="container">
<Button text="Update Time" on={buttonEventHandlers} /> <Button
text="Update Time"
on={{
clicked: () => setTime(`${new Date()}`)
}}
/>
<Text id="result">{time}</Text> <Text id="result">{time}</Text>
</View> </View>
</Window> </Window>

Loading…
Cancel
Save