-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to return a react element in eventRender function #12
Comments
Because info.el is more than a simple JSX element you can't just replace all of that. However there are some ways you can edit info.el to your liking:
customEventRender = info => {
// edit the parent's class
info.el.className = "custom-event-container fc-day-grid-event fc-h-event fc-event fc-start fc-end"
// edit the child's class
info.el.children[0].className = "custom-event-container fc-content"
return info.el
};
customEventRender = info => {
info.el.firstChild.innerText = "Text Overwrite"
return info.el
}; Let me know if there is a certain part of the element you are trying to change and if this info is helpful. |
Thank you, this is exactly what I wanted to know. |
I'm reopening this up because it might be a nice API to allow for returning a JSX element. I've been thinking about this recently because it came up in the Vue repo (fullcalendar/fullcalendar-vue#14) |
FYI, it seems that in my codepen I should not have been trying to return a React element that wraps One possible use-case that I was thinking of was to create/use a tooltip component, such as how Antd does their Popover component, as an alternative to using Tooltip.js as described in the Fullcalendar docs. |
I would love it if this could let us just return arbitrary JSX - it would make things far easier to customize. |
One note, my initial codepen suggested that |
Any update on this? Especially as the convention is to use more functional components in react... Looks like the corresponding vue issue was closed without resolution. |
I get the same issue as @tgandee79, Using the |
A temporary fix I found was to force the row height to be automatic, eg:
This overwrites the inline styles that full calendar adds. |
If you're curious to know, this will be included in v5 (currently in-development) |
@arshaw Very cool! I'm looking forward to upgrading. |
I picked up on advise on this thread and did something like this -
The colors listed out in the CSS appear muted/dull. I've used the same green color (#0acf4b) on FullCalendar vs another custom React Component, but the opacity levels seem to be very different? Is there anything I can do to preserve the opacity/vibrancy? Green on the side bar. Green on the dot/circle icon on March 5th box. |
Just a heads up for anyone trying to use ReactDOM.render to return React Component for calendar event. By default the created ReactDOM tree is not removed which lead to choppy interactions with events in my case. You should add eventDestroy handler like this: eventRender:
eventDestory:
|
this is available in the latest v5-beta here's an example using the new |
vdom nodes are accepted in many places, not just for events. please see all the *Content settings in the upgrade guide: https://fullcalendar.io/docs/v5/upgrading-from-v4 |
Also having the same issue as @tgandee79 but with the resourceTimelinePlugin. The calendar cells are not adjusting to the event size on the first render, using the Is there a fix/solution for this yet? |
Hey @leesh22 , could you post a runnable, stripped-down demonstration of the bug? also, maybe try v5.0.0-beta.3. i fixed a number of event positioning bugs in that release |
@arshaw Ah I didn't realise there was a beta.3 - that update fixed the issue :) - thanks for the speedy response! |
What strategy do I have to use to wrap existing content with a React component e.g. with MUI Tooltip? I posted this solution, but then I noticed that it doesn't fit for different view types, e.g. |
Sorry, I never updated this ticket. This is now possible in v5: @Gustl22 the eventDidMount hook is likely what you need |
@arshaw Unlike Tooltip.js I cannot attach the tooltip to a rendered element. The content must be wrapped inside the MUI Tooltip before rendering:
Whereas |
This issue is still there |
@Gustl22 same problem here I used eventContent hook todo that but still can't accesss the wrapper |
@bahachammakhi I opened an issue for that, you can see, like and comment your opinion there fullcalendar/fullcalendar#5927 and try reproduce the examples Thank you! 🙏 |
I'd like to be able to return a JSX-style react element in the eventRender function, like in the customEventRender method in this CodePen:
https://codesandbox.io/embed/p7kyyr14ym
If I try this now I get
TypeError: can't define property "fcSeg": Object is not extensible.
Let me know if I need to provide more info to describe this.
The text was updated successfully, but these errors were encountered: