æ¤è¨¼ç°å¢
Windows11 Home Edition (version 23H2) D:\>wsl --version WSL ãã¼ã¸ã§ã³: 2.1.5.0 ã«ã¼ãã« ãã¼ã¸ã§ã³: 5.15.146.1-2 WSLg ãã¼ã¸ã§ã³: 1.0.60 MSRDC ãã¼ã¸ã§ã³: 1.2.5105 Direct3D ãã¼ã¸ã§ã³: 1.611.1-81528511 DXCore ãã¼ã¸ã§ã³: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows ãã¼ã¸ã§ã³: 10.0.22631.3296 # installed ubuntu version Ubuntu 22.04.4 LTS (Jammy Jellyfish) # docker Docker version 25.0.3, build 4debf41 Docker Compose version v2.24.6
React ã®ã¤ã³ã¹ãã¼ã«
ä¸è¨ãµã¤ãã®æé ã§ã¤ã³ã¹ãã¼ã«ãã¾ã
ã½ã¼ã¹ã³ã¼ã
create-react-app
ã§ä½æãããã½ã¼ã¹ã³ã¼ããå¤æ´ãã¾ã
react_example/react-app/src/App.tsx
function App() { return ( <div className="App"> <h1>Hello World</h1> </div> ); } export default App;
react_example/react-app/src/index.tsx
import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement ); root.render( <React.StrictMode> <App /> </React.StrictMode> ); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals reportWebVitals();
ã¢ããªã±ã¼ã·ã§ã³ã®èµ·å
ä¸è¨ã®ã³ãã³ããå®è¡ãã¦ã³ã³ãããèµ·åãããã¨ã§ React ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãã¾ã
$ cd react_example $ docker compose up -d
WEB ãã©ã¦ã¶ã§ http://localhost:3000 ã«ã¢ã¯ã»ã¹ãã㨠Hello World ã表示ããã¾ã
CSS ã®è¿½å
App.css
ãä½æãã¾ã
react_example/react-app/src/App.css
.App { text-align: center; } .title { color: red; }
App.tsx
ãä¸è¨å
容ã«å¤æ´ãã¾ã
react_example/react-app/src/App.tsx
import './App.css'; function App() { return ( <div className="App"> <h1 className="title">Hello World</h1> </div> ); } export default App;
WEB ãã©ã¦ã¶ã§ http://localhost:3000 ã«ã¢ã¯ã»ã¹ããã¨ä»¥ä¸ã®ç»åã®éã CSS ãé©ç¨ããã Hello World ã表示ããã¾ã