将变量传递给反应组件

Passing variable to react component

我有:

        function Button(){
        /*.. useQuery ...*/
         const onClick = props => (
         console.log(props.target.value)
           )
        return(
          /*  ... */
            <button value={id} onClick={onClick} >details</button>
        )
        }
我想将 props.target.value 传递给 class react.component。它将用于显示弹出窗口的位置。 我想要这样的东西:
class Details extends React.Component{
/* if thereIsID == 0 then "" or if thereIsID == not 0 then show popup with data according to props.target.value */
}
我使用了许多不同的变体。也许我尝试的方法不正确? 你能推荐一些东西吗?

import React, { useState } from 'react';
import './style.css';

function Button({ onClickHandler }) {
  /*.. useQuery ...*/
  const onClick = (props) => {
    onClickHandler(props.target.value);
  };
  return (
    /*  ... */
    <button value={1} onClick={onClick}>
      details
    </button>
  );
}

class Details extends React.Component {
  /* if thereIsID == 0 then "" or if thereIsID == not 0 then show popup with data according to props.target.value */

  render() {
    return (
      <div>
        Details of Details : {this.props.detail === 0 ? '00000' : 'not 0000000'}
      </div>
    );
  }
}

export default function App() {
  const [show, setShow] = useState(false);
  const [detail, setDetail] = useState('');

  const onClickHandler = (val) => {
    setDetail(val);
    setShow((prev) => !prev);
  };

  return (
    <div>
      <Button onClickHandler={onClickHandler} />
      {show && <Details detail={detail} />}
    </div>
  );
}

Link 测试:https://react-sjsxn2.stackblitz.io