summaryrefslogtreecommitdiffstats
path: root/tests/syntax-tests/highlighted/TypeScriptReact/app.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/syntax-tests/highlighted/TypeScriptReact/app.tsx')
-rw-r--r--tests/syntax-tests/highlighted/TypeScriptReact/app.tsx35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/syntax-tests/highlighted/TypeScriptReact/app.tsx b/tests/syntax-tests/highlighted/TypeScriptReact/app.tsx
new file mode 100644
index 00000000..4fafc1ee
--- /dev/null
+++ b/tests/syntax-tests/highlighted/TypeScriptReact/app.tsx
@@ -0,0 +1,35 @@
+import * as React from "react";
+import { HelloComponent } from "./hello";
+import { NameEditComponent } from "./nameEdit";
+
+export const App = () => {
+ const [name, setName] = React.useState("defaultUserName");
+ const [editingName, setEditingName] = React.useState("defaultUserName");
+
+ const loadUsername = () => {
+ setTimeout(() => {
+ setName("name from async call");
+ setEditingName("name from async call");
+ }, 500);
+ };
+
+ React.useEffect(() => {
+ loadUsername();
+ }, []);
+
+ const setUsernameState = () => {
+ setName(editingName);
+ };
+
+ return (
+ <>
+ <HelloComponent userName={name} />
+ <NameEditComponent
+ initialUserName={name}
+ editingName={editingName}
+ onNameUpdated={setUsernameState}
+ onEditingNameUpdated={setEditingName}
+ />
+ </>
+ );
+};