DEV Community

adriangheo
adriangheo

Posted on

02.08 React State - font color from input (functional components)

App preview:
The way the app will look like

Project files:
An image of project file structure


import React, { useState } from "react";
import "./App.css"

function App(){
  const [color, setColor] = useState('darkBlue');

  return (
    <div className="app" style={{color: color}}>
      <h1>Hello World!</h1>
      <input 
        type="input" 
        onChange={ (event) => {
          console.log(event.target.value)
          setColor(event.target.value);
        }} 
      />
    </div>
  );
}

export default App;
Enter fullscreen mode Exit fullscreen mode

.app{
    background-color: lightskyblue;
    padding: 20px 10px;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)