JavaScript por Radu TM • June 16, 2022
import React, { useState } from 'react';
const Line = () => {
// o gancho useState nos permite acessar o estado em um componente funcional
const [color, setColor] = useState('black');
return (
<div>
<h3>Desenhar uma linha horizontal no React</h3>
<hr
style={{
color: color,
backgroundColor: color,
height: 5
}}
/>
<button onClick={() => setColor('green')}>Verde</button>
<button onClick={() => setColor('blue')}>Azul</button>
<button onClick={() => setColor('red')}>Vermelho</button>
</div>
);
};
export default Line;
0
27.763
JavaScript por Radu TM • June 16, 2022
import React from "react";
//Desenhe uma linha horizontal no React
const HorizontalLine = () => {
return (
<hr
style={{
color: "lightgray",
backgroundColor: "lightgray",
height: 1,
border: "none",
}}
/>
);
};
export default HorizontalLine;
0
27.763