How to pass props to React Big Calendar custom components?

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm using React Big Calendar with custom event components.

In my custom component, I need to display a few buttons which a user can click (via popover). I got the popup thing working fine, but I also want the class that renders BigCalendar to get notified when a button in the popover is clicked. How do we pass an "onButtonClick" event to my custom component as props? Here's a simplified version of my code

class Parent extends Component {

    popoverButtonClickHandler = (e) => {
        //handle button click
    }

    render() {
        return (
            <BigCalendar
                ...
                events={myEvents}
                components={{
                    event: CustomEvent
                }}
            />
        );
    }
}

And here's my CustomEvent class

class CustomEvent extends Component {
    render() {
        return (
            <div>
                <p>My event title: {this.props.title}p>
                <MyPopover>
                    <Button onClick={this.props.onPopoverButtonClick}>
                MyPopover>
            div>
        )
    }
}

I'm trying to figure out how I can pass

onPopoverButtonClick={this.popoverButtonClickHandler}

to my CustomEvent so that Parent will be notified when the button is clicked.

Any ideas how I can achieve this? Thanks

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.