如何将道具从自定义事件传递到 React Big Calendar?

How to pass props to React Big Calendar from custom event?

我需要你的帮助。 我在反应大日历中有一个自定义事件,里面有一个按钮。当我点击按钮时,我想将一个值传递给日历组件。

我不知道该怎么做。你能帮助我吗?谢谢!

export const Schedule = (params) => {
 const [value, setValue] = useState(null);
 const onClickHandler = (e) => {
    e.preventDefault();
    setValue("aaa");
  };
return (
  <Calendar
    components={{event.CustomEvent}}
    eventPropGetter={(event) => ({
       style: {
         borderLeft: "5px solid",
         display: "block",
       },
    })}
    events={events}
  />
)
} 

和 EventComponent


const EventComponent = (props) => {
  const BtnChangeValue = () => {
    return (
      <>
        <button onClick = {setValue("this should change value from Calendar")}></button
      </>
    );
  };

 return(
   <>
     <div>aaaaaa</div>
     <BtnChangeValue onClick={????} />
     <div>eeeee</div>
   </>
 )
}

将您的 components 属性更改为:

components={{event: () => <CustomEvent onClick={onClickHandler}/>}}

在您的 EventComponent 中,像这样传递道具 onClick

const EventComponent = (props) => {
  const BtnChangeValue = ({ ...args }) => {
    return (
      <>
        <button {...args}></button
      </>
    );
  };

 return(
   <>
     <div>aaaaaa</div>
     <BtnChangeValue onClick={props.onClick} />
     <div>eeeee</div>
   </>
 )
}