Using React js inside an Ember project and importing a library using import from 'npm:' gives an unexpected...











up vote
1
down vote

favorite
1












I've seen many other posts with a similar issue but I couldn't find any valid solution to my case.



A bit of background:



I'm working inside an Ember application, where React is being used to develop new components (we are replacing the old ember code, using React).



So far everything works fine and we are able to create and use React components inside Ember without any issues.



Problem:



One of the React component I'm writing needs to use a range date picker and I've found several utilities that do that.
I've deleted all the unnecessary code from the component:



import React from 'npm:react';
import DayPickerInput from 'npm:react-day-picker/DayPickerInput';

export default class ContractDetails extends React.Component {

constructor(props) {
super(props);
}

render() {
return (
<div>
<DayPickerInput/>
</div>
);
}
}


Every time I try to render it I get the following error:



Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object


Reading the other posts, I tried to replace:



import DayPickerInput from 'npm:react-day-picker/DayPickerInput';


With:



import {DayPickerInput} from 'npm:react-day-picker/DayPickerInput';


But I get a similar result (note the error now says it's getting an undefined rather than an object):



Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `ContractDetails`.


The only thing that prevent the error to appear is to use:



<DayPickerInput.default/>


Which, however, causes issue with the library css.



I've tried to replace this library with many others but I always get the same error, so I'm excluding an error within the library itself.



Do you have any clues why I'm getting this error?



I'm using the latest react version (16.6.3)










share|improve this question






















  • It's the first time I see this.. I'm curious, how much your application weight ?
    – Djamel
    Nov 15 at 16:45










  • It's a fairly big Ember application. We are slowing rewriting it using React
    – S.Pesenti
    Nov 15 at 17:24






  • 1




    If you want to rewrite app in another framework - it is easier to just start from zero in emprty repo, imho. As for your question - try import DPInput from 'npm:react-day-picker/DayPickerInput'; const DayPickerInput = DPInput.default;. I'm not sure this will help, it's just a guess.
    – Gennady Dogaev
    Nov 16 at 22:18















up vote
1
down vote

favorite
1












I've seen many other posts with a similar issue but I couldn't find any valid solution to my case.



A bit of background:



I'm working inside an Ember application, where React is being used to develop new components (we are replacing the old ember code, using React).



So far everything works fine and we are able to create and use React components inside Ember without any issues.



Problem:



One of the React component I'm writing needs to use a range date picker and I've found several utilities that do that.
I've deleted all the unnecessary code from the component:



import React from 'npm:react';
import DayPickerInput from 'npm:react-day-picker/DayPickerInput';

export default class ContractDetails extends React.Component {

constructor(props) {
super(props);
}

render() {
return (
<div>
<DayPickerInput/>
</div>
);
}
}


Every time I try to render it I get the following error:



Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object


Reading the other posts, I tried to replace:



import DayPickerInput from 'npm:react-day-picker/DayPickerInput';


With:



import {DayPickerInput} from 'npm:react-day-picker/DayPickerInput';


But I get a similar result (note the error now says it's getting an undefined rather than an object):



Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `ContractDetails`.


The only thing that prevent the error to appear is to use:



<DayPickerInput.default/>


Which, however, causes issue with the library css.



I've tried to replace this library with many others but I always get the same error, so I'm excluding an error within the library itself.



Do you have any clues why I'm getting this error?



I'm using the latest react version (16.6.3)










share|improve this question






















  • It's the first time I see this.. I'm curious, how much your application weight ?
    – Djamel
    Nov 15 at 16:45










  • It's a fairly big Ember application. We are slowing rewriting it using React
    – S.Pesenti
    Nov 15 at 17:24






  • 1




    If you want to rewrite app in another framework - it is easier to just start from zero in emprty repo, imho. As for your question - try import DPInput from 'npm:react-day-picker/DayPickerInput'; const DayPickerInput = DPInput.default;. I'm not sure this will help, it's just a guess.
    – Gennady Dogaev
    Nov 16 at 22:18













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I've seen many other posts with a similar issue but I couldn't find any valid solution to my case.



A bit of background:



I'm working inside an Ember application, where React is being used to develop new components (we are replacing the old ember code, using React).



So far everything works fine and we are able to create and use React components inside Ember without any issues.



Problem:



One of the React component I'm writing needs to use a range date picker and I've found several utilities that do that.
I've deleted all the unnecessary code from the component:



import React from 'npm:react';
import DayPickerInput from 'npm:react-day-picker/DayPickerInput';

export default class ContractDetails extends React.Component {

constructor(props) {
super(props);
}

render() {
return (
<div>
<DayPickerInput/>
</div>
);
}
}


Every time I try to render it I get the following error:



Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object


Reading the other posts, I tried to replace:



import DayPickerInput from 'npm:react-day-picker/DayPickerInput';


With:



import {DayPickerInput} from 'npm:react-day-picker/DayPickerInput';


But I get a similar result (note the error now says it's getting an undefined rather than an object):



Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `ContractDetails`.


The only thing that prevent the error to appear is to use:



<DayPickerInput.default/>


Which, however, causes issue with the library css.



I've tried to replace this library with many others but I always get the same error, so I'm excluding an error within the library itself.



Do you have any clues why I'm getting this error?



I'm using the latest react version (16.6.3)










share|improve this question













I've seen many other posts with a similar issue but I couldn't find any valid solution to my case.



A bit of background:



I'm working inside an Ember application, where React is being used to develop new components (we are replacing the old ember code, using React).



So far everything works fine and we are able to create and use React components inside Ember without any issues.



Problem:



One of the React component I'm writing needs to use a range date picker and I've found several utilities that do that.
I've deleted all the unnecessary code from the component:



import React from 'npm:react';
import DayPickerInput from 'npm:react-day-picker/DayPickerInput';

export default class ContractDetails extends React.Component {

constructor(props) {
super(props);
}

render() {
return (
<div>
<DayPickerInput/>
</div>
);
}
}


Every time I try to render it I get the following error:



Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object


Reading the other posts, I tried to replace:



import DayPickerInput from 'npm:react-day-picker/DayPickerInput';


With:



import {DayPickerInput} from 'npm:react-day-picker/DayPickerInput';


But I get a similar result (note the error now says it's getting an undefined rather than an object):



Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `ContractDetails`.


The only thing that prevent the error to appear is to use:



<DayPickerInput.default/>


Which, however, causes issue with the library css.



I've tried to replace this library with many others but I always get the same error, so I'm excluding an error within the library itself.



Do you have any clues why I'm getting this error?



I'm using the latest react version (16.6.3)







javascript reactjs ember.js






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 at 16:05









S.Pesenti

61




61












  • It's the first time I see this.. I'm curious, how much your application weight ?
    – Djamel
    Nov 15 at 16:45










  • It's a fairly big Ember application. We are slowing rewriting it using React
    – S.Pesenti
    Nov 15 at 17:24






  • 1




    If you want to rewrite app in another framework - it is easier to just start from zero in emprty repo, imho. As for your question - try import DPInput from 'npm:react-day-picker/DayPickerInput'; const DayPickerInput = DPInput.default;. I'm not sure this will help, it's just a guess.
    – Gennady Dogaev
    Nov 16 at 22:18


















  • It's the first time I see this.. I'm curious, how much your application weight ?
    – Djamel
    Nov 15 at 16:45










  • It's a fairly big Ember application. We are slowing rewriting it using React
    – S.Pesenti
    Nov 15 at 17:24






  • 1




    If you want to rewrite app in another framework - it is easier to just start from zero in emprty repo, imho. As for your question - try import DPInput from 'npm:react-day-picker/DayPickerInput'; const DayPickerInput = DPInput.default;. I'm not sure this will help, it's just a guess.
    – Gennady Dogaev
    Nov 16 at 22:18
















It's the first time I see this.. I'm curious, how much your application weight ?
– Djamel
Nov 15 at 16:45




It's the first time I see this.. I'm curious, how much your application weight ?
– Djamel
Nov 15 at 16:45












It's a fairly big Ember application. We are slowing rewriting it using React
– S.Pesenti
Nov 15 at 17:24




It's a fairly big Ember application. We are slowing rewriting it using React
– S.Pesenti
Nov 15 at 17:24




1




1




If you want to rewrite app in another framework - it is easier to just start from zero in emprty repo, imho. As for your question - try import DPInput from 'npm:react-day-picker/DayPickerInput'; const DayPickerInput = DPInput.default;. I'm not sure this will help, it's just a guess.
– Gennady Dogaev
Nov 16 at 22:18




If you want to rewrite app in another framework - it is easier to just start from zero in emprty repo, imho. As for your question - try import DPInput from 'npm:react-day-picker/DayPickerInput'; const DayPickerInput = DPInput.default;. I'm not sure this will help, it's just a guess.
– Gennady Dogaev
Nov 16 at 22:18

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323418%2fusing-react-js-inside-an-ember-project-and-importing-a-library-using-import-from%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323418%2fusing-react-js-inside-an-ember-project-and-importing-a-library-using-import-from%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents