frontend-hamroun 1.1.45 → 1.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -2,14 +2,17 @@ import { render, useState, Link, useRouter } from 'frontend-hamroun';
|
|
2
2
|
|
3
3
|
// Home component
|
4
4
|
function Home() {
|
5
|
-
const [count, setCount] = useState(0);
|
5
|
+
const [count, setCount] = useState<number>(0);
|
6
|
+
|
7
|
+
const displayCount = typeof count === 'number' ? count : 0;
|
8
|
+
|
6
9
|
return (
|
7
10
|
<div>
|
8
11
|
<h1>Home Page</h1>
|
9
12
|
<div>
|
10
|
-
<button onClick={() => setCount(
|
11
|
-
<span style={{ margin: '0 10px' }}>{
|
12
|
-
<button onClick={() => setCount(
|
13
|
+
<button onClick={() => setCount((prev) => (typeof prev === 'number' ? prev - 1 : 0))}>-</button>
|
14
|
+
<span style={{ margin: '0 10px' }}>{displayCount}</span>
|
15
|
+
<button onClick={() => setCount((prev) => (typeof prev === 'number' ? prev + 1 : 0))}>+</button>
|
13
16
|
</div>
|
14
17
|
</div>
|
15
18
|
);
|
@@ -42,8 +45,8 @@ function App() {
|
|
42
45
|
return (
|
43
46
|
<div>
|
44
47
|
<Navigation />
|
45
|
-
{router.pathname === '/'
|
46
|
-
{router.pathname === '/about'
|
48
|
+
{router.pathname === '/' ? <Home /> : null}
|
49
|
+
{router.pathname === '/about' ? <About /> : null}
|
47
50
|
</div>
|
48
51
|
);
|
49
52
|
}
|