Starter Code

The Starter Code

Solution Code

The Solution Code

Objectives

Step 1:

Talk about imports and exports.

Explain that we will be creating seperate components today for the project. We will take the counter component and the color picker from the break out yesterday and combine them into one application. We will need to export each component and import them in to the main index.js file.

https://www.geeksforgeeks.org/reactjs-importing-exporting/

import ColorPicker from "./components/ColorPicker";
import Counter from "./components/Counter";
function App() {
  return (
    <div className="counter">
      <ColorPicker />
      <Counter />
    </div>
  );
}

Step 2:

Set up Counter and CounterButton components

Set up your first 2 components. Talk about passing props between parent and child components. Highlight the number and buttonValue props that is passed between the Counter and CounterButton components. Console.log props and show students the values you get.