I am trying to pass value "red" from index.js to box.js yet not working. Basically, I have a component that defines property of box and I want to pass background color "red" from index.js to Box.js component.
// Box.js import React from "react"; const box = { // here i would like to get the vlue name assign it to background background: this.props.name, width: "250px", height: "250px" // more code that defines how the box looks like here }; export default Box; /// index.js import React, { Component } from "react"; import { render } from "react-dom"; import Box from "./Box"; render() { return ( // when calling Box, I would like to pass the value red to varivable name as shown below <Box name="red"></Box> ) } What am I missing?
props.