parent component controls subcomponents to display problems through configuration items
p1.js parent component
import React, { Component } from "react";
import Child from "../child"
export default P1 extends Component {
constructor() {
super()
this.state = {
arr: [
{
text:"01",
time:10
},
{
text:"02",
time:20
}
]
}
//child
//:ptime :
//: time:10state10 10~20div
export default Child extends Component {
constructor (props) {
super(props)
this.state = {
istate:true,
color: "gray", //
text:"0001"
}
this.show = props.options // arr
//..
}
render() {
return (
<div style={`color:${this.state.color}`}>
{ this.state.text }
</div>
);
}
}
not long after watching react, I asked the great god for advice.