Commit d2d0995b authored by Illia Baida's avatar Illia Baida

Prepare app

parent 47d4c0f5
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,7 +3,7 @@
}
.App-logo {
height: 40vmin;
height: 10vmin;
pointer-events: none;
}
......@@ -24,10 +24,6 @@
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
......
import React from 'react';
import logo from './logo.svg';
import './App.css';
import React, { useEffect, useCallback, useState, useMemo } from "react";
import logo from "./logo.svg";
import "./App.css";
const Inputs = { toDecimal: "toDecimal", toRoman: "toRoman" };
function App() {
// form
const [toDecimalValue, setToDecimalValue] = useState("");
const [toRomanValue, setToRomanValue] = useState("");
const handleChange = useCallback(e => {
e.preventDefault();
const value = e.target.value.trim().toUpperCase();
if (value) {
if (e.target.name === Inputs.toDecimal) {
setToDecimalValue(value);
} else {
setToRomanValue(value);
}
}
}, []);
useEffect(() => {
console.log(toDecimalValue, toRomanValue);
}, [toDecimalValue, toRomanValue]);
// convert values
const converted = useMemo(() => {
const romanToBeConverted = toDecimalValue;
const decimalToBeConverted = toRomanValue;
return {
toDecimal: 499,
toRoman: 'CDXCIX'
};
}, [toDecimalValue, toRomanValue]);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
<h2>Converter: Roman to Decimal</h2>
<input name={Inputs.toDecimal} onChange={handleChange} />
<span>Value is: {converted.toDecimal}</span>
<h2>Converter: Decimal to Roman</h2>
<input name={Inputs.toRoman} onChange={handleChange} />
<span>Value is: {converted.toRoman}</span>
</header>
</div>
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment