Skip to content
This repository was archived by the owner on Oct 9, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15,619 changes: 15,619 additions & 0 deletions react-examples/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions react-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@testing-library/user-event": "^12.1.10",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
Expand Down
14 changes: 5 additions & 9 deletions react-examples/src/App.js → react-examples/src/Home/index.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Welcome from './Welcome';
import { Counter } from './Counter';
import './App.css';
import { Form } from './Form';
import { Interval } from './Interval';
import Welcome from '../Welcome';
import { Counter } from '../Counter';
import './Home.css';
import { Form } from '../Form';

function App() {
export const Home = () => {
const names = ["Ceci"];

return (
Expand All @@ -17,10 +16,7 @@ function App() {
))}
<Counter />
<Form />
<Interval />
</header>
</div>
);
}

export default App;
9 changes: 0 additions & 9 deletions react-examples/src/Interval.jsx

This file was deleted.

13 changes: 13 additions & 0 deletions react-examples/src/Interval/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { useEffect } from 'react';

export const Interval = () => {
useEffect(() => {
const interval = setInterval(() => console.log('interval!'), 1000)

return () => clearInterval(interval);
}, []);

return <div>
Interval
</div>
}
11 changes: 11 additions & 0 deletions react-examples/src/Navbar/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { Link } from 'react-router-dom';

export const Navbar = () => {
return (
<nav>
<Link to='/'>Home</Link>
<Link to='/interval'>Interval</Link>
</nav>
)
};
22 changes: 22 additions & 0 deletions react-examples/src/Root/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { BrowserRouter, Switch, Route } from 'react-router-dom';

import { Home } from '../Home';
import { Interval } from '../Interval';
import { Navbar } from '../Navbar'

export const Root = () => {
return (
<BrowserRouter>
<Navbar />
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route path="/interval">
<Interval />
</Route>
</Switch>
</BrowserRouter>
);
}
3 changes: 3 additions & 0 deletions react-examples/src/Welcome/Welcome.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.App {
color: aqua;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';

import styles from './Welcome.module.css';

const Welcome = ({ name, children, onClick }) => (
<>
{name
? <h1 onClick={() => onClick(name)}>Welcome, {name}!</h1>
? <h1 className={styles.App} onClick={() => onClick(name)}>Welcome, {name}!</h1>
: <h1 onClick={() => onClick('Stranger')}>Welcome, Stranger!</h1>}
{children}
</>
Expand Down
4 changes: 2 additions & 2 deletions react-examples/src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { Root } from './Root';
import reportWebVitals from './reportWebVitals';

ReactDOM.render(
<React.StrictMode>
<App />
<Root />
</React.StrictMode>,
document.getElementById('root')
);
Expand Down