小编Anu*_*hra的帖子

如何在(条件渲染)中使用 ref

我想使用 ref,但是我无法在最初为 false 的条件渲染中使用它。

constructor(props) {
    super(props);
    this.state = { 
      filterActive: false,
    }
    this.firstRef = React.createRef();

}
Run Code Online (Sandbox Code Playgroud)

如果我在此使用 ref :-

{this.state.filterActive ?
    <label ref={this.firstRef}>Time Range</label>
:null}
Run Code Online (Sandbox Code Playgroud)

引用为空。

javascript render ref conditional-statements reactjs

6
推荐指数
1
解决办法
2903
查看次数

如何在引导程序 4 中居中图像?

我是 Bootstrap 4 的新手,在 Bootstrap 3 的早期我们使用类“center-block”,现在我无法在新版本中找到它。

html css image twitter-bootstrap twitter-bootstrap-4

-1
推荐指数
2
解决办法
2万
查看次数