-
-
Notifications
You must be signed in to change notification settings - Fork 766
Closed
Description
@LeoAref reported in this message that requiring the component via commonjs would throw an invariant violation:
var DayPicker = require('react-day-picker');console output:
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
A temporary workaround is to use the exported default object:
var DayPicker = require('react-day-picker').default;The way of exporting in the main script doesn't indeed consider this case, so instead of writing
"use strict";
module.exports = require("./lib/DayPicker");
module.exports.DateUtils = require("./lib/DateUtils");
module.exports.LocaleUtils = require("./lib/LocaleUtils");I'd put
"use strict";
var DayPicker = require("./lib/DayPicker");
var DateUtils = require("./lib/DateUtils");
var LocaleUtils = require("./lib/LocaleUtils");
module.exports = DayPicker.default || DayPicker;
module.exports.DateUtils = DateUtils.default || DateUtils;
module.exports.LocaleUtils = LocaleUtils.default || LocaleUtils;...considering we must support webpack, commonjs, babel 5 and babel 6 😅
I tag this as breaking change since users may already require using the above workaround.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels