Skip to content
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

Error: Element type is invalid #5205

Open
cquillen2003 opened this issue Nov 2, 2024 · 2 comments
Open

Error: Element type is invalid #5205

cquillen2003 opened this issue Nov 2, 2024 · 2 comments

Comments

@cquillen2003
Copy link

The basic example, the first example shown in the docs is not working for me. I get the following error:

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

@VogelDevelopment
Copy link

had the same problem, seriously needs to be fixed. I came across this workaround:
#1333 (comment)

and that works well for me, even though it's not clean it does the job until the actual problem gets fixed

@teknosains
Copy link

teknosains commented Jan 5, 2025

its 2025 now and Got the same problem on SSR (Remix)

Here's my work around using @radoslawgrochowski's workaround

wrap it in a component

/components/DatePicker.tsx

import * as RDP from 'react-datepicker';
import "react-datepicker/dist/react-datepicker.css";

// this is a workaround for react-datepicker issue
// https://github.com/Hacker0x01/react-datepicker/issues/1333#issuecomment-1251934708

const DatePickerBase = (((RDP.default as any).default as any) ||
  (RDP.default as any) ||
  (RDP as any)) as typeof RDP.default

export const DatePicker = (props: any) => {

  return (
    <DatePickerBase 
      {...props}
      showIcon
    />
  );
};

use it like

import { DatePicker } from "~/components/DatePicker";

// ...

<DatePicker
    name="order_date"
    selected={order_date}
    onChange={handleChangeDate}
    dateFormat="dd-MM-yyyy"
  />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants