From e4d027a1246b12e1e2e6dd7e9651d4e8e4b1b8e9 Mon Sep 17 00:00:00 2001 From: Emanuel Quintino Date: Wed, 6 Dec 2023 14:12:59 -0300 Subject: [PATCH] add typescript example --- 6-React/class-02-components/src/main.tsx | 12 ++++++------ 6-React/class-02-components/src/pages/App.tsx | 6 ++---- 6-React/class-02-components/src/typescript.ts | 12 ++++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 6-React/class-02-components/src/typescript.ts diff --git a/6-React/class-02-components/src/main.tsx b/6-React/class-02-components/src/main.tsx index 89abd699..d630d9bc 100644 --- a/6-React/class-02-components/src/main.tsx +++ b/6-React/class-02-components/src/main.tsx @@ -1,9 +1,9 @@ -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './pages/App.tsx' +import React from "react"; +import ReactDOM from "react-dom/client"; +import { App } from "./pages/App.tsx"; -ReactDOM.createRoot(document.getElementById('root')!).render( +ReactDOM.createRoot(document.getElementById("root")!).render( - , -) + +); diff --git a/6-React/class-02-components/src/pages/App.tsx b/6-React/class-02-components/src/pages/App.tsx index c123f1fa..4e27be24 100644 --- a/6-React/class-02-components/src/pages/App.tsx +++ b/6-React/class-02-components/src/pages/App.tsx @@ -1,12 +1,10 @@ import { CardProfile } from "../components/CardProfile"; -function App() { +export function App() { return ( <> -

Class Components

+

Class Components

); } - -export default App; diff --git a/6-React/class-02-components/src/typescript.ts b/6-React/class-02-components/src/typescript.ts new file mode 100644 index 00000000..28a3ea8a --- /dev/null +++ b/6-React/class-02-components/src/typescript.ts @@ -0,0 +1,12 @@ +type User = { + name: string; + age: number; +}; + +function user(user: User) { + console.log(user); + console.log(user.name); + console.log(user.age); +} + +user({ name: "Emanuel", age: 30 });