0

I have common react-components like Button, Checkbox, Datepicker etc.,. I am transpiling using the rollup.config.js. For date picker I am using react-datepicker. All these components are used in all the other create-react-app application.

For Datepicker, I am getting the below error,

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

Check the render method of `x`.
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `x`.
    at createFiberFromTypeAndProps (http://localhost:3000/static/js/bundle.js:80958:21)
    at createFiberFromElement (http://localhost:3000/static/js/bundle.js:80979:19)
...

react-components/CustomDatePicker/CustomDatePicker.jsx

import React from 'react';
import DatePicker from 'react-datepicker';

export default function CustomDatePicker() {
    return (
        <DatePicker selected={new Date()} onChange={(date) => { }} />
    );
}

react-palyground/Datepicker/Datepicker.jsx

import React from 'react';
import 'react-datepicker/dist/react-datepicker.module.css';
import { CustomDatePicker } from '[Organization-folder]/oneems-react-components';

export default function DatepickerElement() {

    return (
        <>
            <h1>Datepicker</h1>
            <CustomDatePicker />
        </>
    );
}


index.js

export { default as Datepicker } from "./DatePicker/DatePicker.jsx";

Can anyone help me to fix this issue?

Thanks in advance.

0

1 Answer 1

0

import { CustomDatePicker } from '[Organization-folder]/oneems-react-components'; => this is wrong.

You have exported CustomDatePicker as default in other file so use as per below statement.

import CustomDatePicker from '[Organization-folder]/oneems-react-components'
Sign up to request clarification or add additional context in comments.

1 Comment

Forgot to include index.js. There DatePicker is default one. I'm sorry I missed the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.