react核心试题解答.docVIP

  • 0
  • 0
  • 约2.69千字
  • 约 6页
  • 2026-08-17 发布于河北
  • 举报

react核心试题解答

一、选择题(每题5分,共30分)

1.以下关于React组件的说法,正确的是()

A.一个React组件必须有render方法

B.函数式组件不能有状态

C.类组件不能使用箭头函数定义

D.组件之间的数据传递只能通过props

2.在React中,以下哪个生命周期方法会在组件挂载到DOM后立即执行()

A.componentWillMount

B.componentDidMount

C.willReceiveProps

D.componentWillReceiveProps

3.当一个React组件的props发生变化时,会触发以下哪个生命周期方法()

A.shouldComponentUpdate

B.componentWillUpdate

C.componentDidUpdate

D.以上都会触发

4.以下代码中,能正确定义一个简单的React组件的是()

A.constMyComponent=()=divHelloReact/div

B.functionMyComponent(){returndivHelloReact/div}

C.classMyComponentextendsReact.Component{render(){returndivHello

文档评论(0)

1亿VIP精品文档

相关文档