Skip to content

Commit

Permalink
react-ts: make sure react-scripts works, use new jsx runtime (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Florens Verschelde authored Sep 1, 2023
1 parent ad31a0e commit f8e4e62
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
20 changes: 12 additions & 8 deletions react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
"name": "react-ts",
"version": "0.0.0",
"private": true,
"dependencies": {
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.2",
"react": "^18.1.0",
"react-dom": "^18.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"dependencies": {
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"react-scripts": "latest"
}
"react-scripts": "^5.0.1",
"typescript": "^4.9.5"
},
"browserslist": [
"defaults"
]
}
9 changes: 5 additions & 4 deletions react-ts/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as React from 'react';
import { FC } from 'react';

import './style.css';

export default function App() {
export const App: FC<{ name: string }> = ({ name }) => {
return (
<div>
<h1>Hello StackBlitz!</h1>
<h1>Hello {name}!</h1>
<p>Start editing to see some magic happen :)</p>
</div>
);
}
};
8 changes: 3 additions & 5 deletions react-ts/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import * as React from 'react';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from './App';
import { App } from './App';

const rootElement = document.getElementById('root');
const root = createRoot(rootElement);
const root = createRoot(document.getElementById('root'));

root.render(
<StrictMode>
<App />
<App name="StackBlitz" />
</StrictMode>
);
8 changes: 8 additions & 0 deletions react-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"lib": ["DOM", "ES2022"],
"moduleResolution": "node",
"target": "ES2022"
}
}

0 comments on commit f8e4e62

Please sign in to comment.