JavaScript de Victor Talmacinschi • June 16, 2022
import React, { useState } from 'react';
const Line = () => {
// useState hook ne permite să accesăm starea într-un component funcțional
const [color, setColor] = useState('black');
return (
<div>
<h3>Trage o linie orizontală în React</h3>
<hr
style={{
color: color,
backgroundColor: color,
height: 5
}}
/>
<button onClick={() => setColor('green')}>Verde</button>
<button onClick={() => setColor('blue')}>Albastru</button>
<button onClick={() => setColor('red')}>Roșu</button>
</div>
);
};
export default Line;
0
28.783
JavaScript de Victor Talmacinschi • June 16, 2022
import React from "react";
//Trage o linie orizontală în React
const HorizontalLine = () => {
return (
<hr
style={{
color: "lightgray",
backgroundColor: "lightgray",
height: 1,
border: "none",
}}
/>
);
};
export default HorizontalLine;
0
28.783