Skip to content

Commit ee056e1

Browse files
committed
feat: Test component for checking the setup
1 parent 443b48d commit ee056e1

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/components/Test.jsx

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React, { useCallback, useState } from "react";
2+
3+
/**
4+
* Renders a test component for checking the ESLint & Prettier setup.
5+
*
6+
* @return {JSX.Element} The rendered test component.
7+
*/
8+
function Test() {
9+
const [username, setUsername] = useState("Alkaison");
10+
11+
const handleUsernameChange = useCallback((e) => {
12+
setUsername(e.target.value);
13+
}, []);
14+
15+
const resetUserNameValue = useCallback(() => {
16+
setUsername("");
17+
}, []);
18+
19+
const setRandomUserName = useCallback(() => {
20+
const randomUserNames = ["Mike", "Tyson", "Jack", "Jill", "Jen", "Fin", "Sam", "Valt", "Kolin", "Jas"];
21+
const index = Math.floor(Math.random() * randomUserNames.length);
22+
setUsername(randomUserNames[index]);
23+
}, []);
24+
25+
return (
26+
<div>
27+
<p>
28+
A test component for checking the ESLint & Prettier setup. Free feel to make error in this component and ESLint
29+
with detect the problems ask to resolve them.
30+
</p>
31+
32+
<p>ESLint checks your code for errors and warnings.</p>
33+
34+
<p>Prettier formats your code on saving the file. Making consistency in your code styles for whole project.</p>
35+
36+
<p>
37+
Created By:{" "}
38+
<a href="https://github.com/Alkaison" target="_blank" rel="noreferrer">
39+
Alkaison
40+
</a>
41+
</p>
42+
43+
<p>Your Name: {username}</p>
44+
45+
<input type="text" placeholder="Your Full Name" value={username} onChange={handleUsernameChange} />
46+
47+
<button type="button" onClick={setRandomUserName}>
48+
Surprise ME!
49+
</button>
50+
51+
<button type="button" onClick={resetUserNameValue}>
52+
Reset
53+
</button>
54+
</div>
55+
);
56+
}
57+
58+
export default Test;

0 commit comments

Comments
 (0)