question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React Vite compatibility

See original GitHub issue

Hello,

Recently we’ve been researching a possibility to move our project to Vite environment. Of course we failed at the first try just because of the same issue as discussed in the Vue integration section of your repository (i.e. https://github.com/fullcalendar/fullcalendar-vue/issues/152 and related). I’ve tried the solution provided there to import @fullcalendar/core/vdom just before anything else connected to fullcalendar packages but it didn’t work very well for a React project. The error I got was:

The <CalendarDataProvider2 /> component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change CalendarDataProvider2 to extend React.Component instead.

and:

Uncaught TypeError: Cannot set property 'props' of undefined.

It definitely concerned the imported vdom not being compatible with Reacts vDOM. So I crawled through internal fullcalendar package files and I found @fullcalendar/react/dist/vdom. When replacing the import the project seems to work.

To sum up I would like to ask the project authors if the described solution is a proper way to run a React Fullcalendar project with a Vite build tool? If so, could the docs be updated (or should I prepare a PR to update them)?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

74reactions
abdellatifLabrcommented, Aug 31, 2021

For everyone who is still getting this error, here is the fix You should put your imports in this order including react vdom

import "@fullcalendar/react/dist/vdom";
import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid";
9reactions
jugglingcatscommented, Nov 20, 2021

I’m running vite too and @abdellatifLabr’s sequence above worked for me (using /react/dist/vdom). For me using /core/vdom did get rid of the first error about import being in the wrong order but I had the following cryptic warnings/errors…

Warning: CalendarRoot2 defines an invalid contextType. contextType should point to the Context object returned by React.createContext(). However, it is set to an object with keys {__c, __, Consumer, Provider}.
...
Uncaught Error: Expected ref to be a function, a string, an object returned by React.createRef(), or null.
...
The above error occurred in the <CalendarContent2> component

(for benefit of others coming here via google)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing Vite 2.0
Plugins can use Rollup-compatible hooks, with additional Vite-specific hooks and properties to adjust Vite-only behavior (e.g. differentiating dev vs. build or ...
Read more >
Vite 3.0 vs. Create React App: Comparison and migration guide
Extensive plugin compatibility​​ Vite leverages the Rollup plugin interface to improve a developer's experience by allowing them to rely on the ...
Read more >
compiled/react compatibility issues with Vite #1237 - GitHub
Describe the bug Not sure if this is necessarily a bug with @compiled/react or if it's an issue with the way Vite pre-bundled...
Read more >
How to set up a Front-End project with Vite, React, and ...
Compatibility Note: Vite requires Node.js version >=12.2.0. Tutorial Node.js version: 16.13.0; Tutorial NPM version: 8.1.0 ...
Read more >
How can i use Buffer, process in Vite app? - Stack Overflow
Buffer = Buffer; window.process = process;. ` But i still get some error ex: "Module "process" has been externalized for browser compatibility.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found