小编tha*_*ndo的帖子

ReactJS:如何在进入DOM时将焦点设置为input-element?

如何input在进入DOM时将焦点设置为元素?

脚本

单击按钮时,将显示输入元素.如何将焦点设置为此元素?

代码片段

class Component extends React.Component{
  constructor(props) {
    super(props);
    this.state = {
      showInput: false
    }
  }

  render() {
      return (
        <div>
          <div onClick={() => {
              this.setState({showInput: true});
              ReactDOM.findDOMNode(this.refs.myInput).focus() // <- NOT WORKING
          }}>
            Show Input
          </div>
          {
            (this.state.showInput) ? (
                <input
                    type="text"
                    ref="myInput"
                />
            ) : ""
          }  
        </div>
      );
  }
}
Run Code Online (Sandbox Code Playgroud)

ReactDOM.findDOMNode(this.refs.myInput).focus()在状态更改后调用不起作用.同时更改状态更改中的styleor type属性也不起作用.

reactjs

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

如何在Meteor 1.3应用程序中结合react-redux和react-meteor-data?

如何使用state属性react-redux来指定注入的数据react-meteor-data

react组件的结构如下:

  import React from "react";
  import {createContainer} from "meteor/react-meteor-data";
  import {connet} from "react-redux";
  import {Data} from "./data.js"

  class App extends React.Component {
     render() {
        return (
           <div>
              {JSON.stringify(this.props.profile)}
           </div>
        );
     }   
  }
  const mapStateToProps = state => ({
      ID: state.dataId    // ID gets assigned to props here
  });

  export default createContainer(
      () => ({
         profile: Data.findOne({_id: >>>ID<<<})   // ID is needed here
      }), 
      connect(mapStateToProps)(App)
  );
Run Code Online (Sandbox Code Playgroud)

非常感谢!

meteor reactjs react-redux

3
推荐指数
1
解决办法
653
查看次数

与管道运算符和 [ 选择器一起使用时,为什么 colnames 函数会生成小标题(而不是矢量)?

问题:为什么该colnames函数与管道操作符%>%[选择器一起使用时会生成一个小标题?

示例:给定以下标题:

library(tidyverse)

x <- tribble(
  ~a, ~b,
  1, 0,
  0, 1
)
Run Code Online (Sandbox Code Playgroud)

问题:当与管道运算符和[选择器一起使用时,colnames 函数会生成一个 tibbe :

x %>% colnames(.)[1]
#> # A tibble: 2 x 1
#>       a
#>   <dbl>
#> 1    NA
#> 2    NA
Run Code Online (Sandbox Code Playgroud)

而我希望它生成一个向量,就好像没有使用管道运算符一样:

colnames(x)[1]
#> [1] "a"
Run Code Online (Sandbox Code Playgroud)

r magrittr tidyverse

3
推荐指数
2
解决办法
73
查看次数

在index.js文件中导出React jsx-components

如何将在jsx文件中定义的react-components捆绑在index.js文件中?

以某种方式可以通过访问组件import module from "/module"; let C = module.Component;

带有:

/module
  index.js
  Component.jsx
Run Code Online (Sandbox Code Playgroud)

jsx reactjs react-jsx

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

标签 统计

reactjs ×3

jsx ×1

magrittr ×1

meteor ×1

r ×1

react-jsx ×1

react-redux ×1

tidyverse ×1