这样可以吗

来源:1-4 自由编程

unbreakable_全栈

2021-01-26 12:07:01

import React, { Component } from "react";

import Children from "./Children";

class Father extends Component {

  constructor(props) {

    super(props);

    this.state = {

      value: "hello world",

    };

  }

  render() {

    return <Children content={this.state.value} />;

  }

}

export default Father;


----------------------------------------------

import React, { Component } from "react";

class Children extends Component {

  render() {

    const { content } = this.props;

    return <div>{content}</div>;

  }

}

export default Children;



写回答

1回答

好帮手慕言

2021-01-26

同学你好,效果是对的,继续加油,祝学习愉快~

0

0 学习 · 10739 问题

查看课程