Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么即使我指定了值,它仍返回null?_Javascript_Reactjs - Fatal编程技术网

Javascript 为什么即使我指定了值,它仍返回null?

Javascript 为什么即使我指定了值,它仍返回null?,javascript,reactjs,Javascript,Reactjs,下面的代码返回null,即使我指定了一个特定的值。我认为问题在于document.getelementbyid('userInput')显然返回null,但我认为这不是100%的情况。 谢谢 从“React”导入React 从“react static”导入{WithRoutedData,Link} // 导出默认WithRoutedData(({Currences})=>( 角隅 克里普托斯 代币 加密/令牌 最小取款数量 最小订单数量 {currency.filter(currency=>

下面的代码返回null,即使我指定了一个特定的值。我认为问题在于
document.getelementbyid('userInput')
显然返回null,但我认为这不是100%的情况。 谢谢

从“React”导入React
从“react static”导入{WithRoutedData,Link}
//
导出默认WithRoutedData(({Currences})=>(
角隅
克里普托斯
代币

加密/令牌 最小取款数量 最小订单数量 {currency.filter(currency=>currency.currency===document.getElementById('userInput').value).map(currency=>( {currency.currency} {货币.最低提款额} {货币.最小订单数量} ))} ))
您可以尝试使用ref而不是document.getElementById来获取值

export default withRouteData(({ currencies }) => (
<div> 

  <Link to="/">Quoinex</Link>
  <Link to="/qryptos"><b>Qryptos</b></Link>
  <form id="form">
    <input type="text" name="name" placeholder="BTC etc." id="userInput" ref="userInput" value="BTC" />
    <input className="sub" type="submit" />
  </form>
  <h1>Tokens</h1>
  <br />
  <table className="myTable">
    <tr>
      <th>Crypto/Token</th>
      <th>Min Withdrawal Qty</th>
      <th>Min Order Qty</th>
    </tr>
    { currencies.filter(currency => currency.currency === React.findDOMNode(this.refs.userInput).value).map(currency => (
      <tr key={currency.currency}>
        <td id="tokenName">{currency.currency}</td>
        <td>{currency.minimum_withdrawal}</td>
        <td>{currency.minimum_order_quantity}</td> 
      </tr>
    ))}
  </table>

</div>
))
export default with routedData(({currencies})=>(
角隅
克里普托斯
代币

加密/令牌 最小取款数量 最小订单数量 {currency.filter(currency=>currency.currency===React.findDOMNode(this.refs.userInput.value).map(currency=>( {currency.currency} {货币.最低提款额} {货币.最小订单数量} ))} ))
export default withRouteData(({ currencies }) => (
<div> 

  <Link to="/">Quoinex</Link>
  <Link to="/qryptos"><b>Qryptos</b></Link>
  <form id="form">
    <input type="text" name="name" placeholder="BTC etc." id="userInput" ref="userInput" value="BTC" />
    <input className="sub" type="submit" />
  </form>
  <h1>Tokens</h1>
  <br />
  <table className="myTable">
    <tr>
      <th>Crypto/Token</th>
      <th>Min Withdrawal Qty</th>
      <th>Min Order Qty</th>
    </tr>
    { currencies.filter(currency => currency.currency === React.findDOMNode(this.refs.userInput).value).map(currency => (
      <tr key={currency.currency}>
        <td id="tokenName">{currency.currency}</td>
        <td>{currency.minimum_withdrawal}</td>
        <td>{currency.minimum_order_quantity}</td> 
      </tr>
    ))}
  </table>

</div>
))