Skip to content
Open
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
11 changes: 7 additions & 4 deletions 11/2/src/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {useEffect, useState} from 'react';
import '../css/main.css';

export default function () {
// Can you use only one state variable? Do you think you should?
const [m, setM] = useState(0);
const [s, setS] = useState(0);
const [h, setH] = useState(0);
Expand All @@ -12,20 +13,22 @@ export default function () {
setM(secunds/60);
setS(secunds);
}
// Please don't use id inside JSX
// If anyone will create multiple instances of this component, they'll get multiple elements with the same id
return (
<>
<div>
<label htmlFor="h">שעות</label>
<input type="number" id="h" value={h} onChange={(e) => converter(e.target.value*3600)}/>
<input type="text" id="h" value={h} onChange={(e) => converter(e.target.value*3600)}/>
</div>
<div>
<label htmlFor="m">דקות</label>
<input type="number" id="m" value={m} onChange={(e) => converter(e.target.value*60)}/>
<input type="text" id="m" value={m} onChange={(e) => converter(e.target.value*60)}/>
</div>
<div>
<label htmlFor="s">שניות</label>
<input type="number" id="s" value={s} onChange={(e) => converter(e.target.value)}/>
<input type="text" id="s" value={s} onChange={(e) => converter(e.target.value)}/>
</div>
</>
)
}
}