Skip to content

Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports #8686

Closed Answered by anudeepreddy
imrostom asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

I faced the same issue and here are my findings. Even if we mark a component client only by appending .client.tsx, remix renders the parent component where we are using this child component both on server side and client side. When it tries to do a server side render and since the Test component is clientonly the import would resolve into {} which is an object hence you see the error.

As a fix try to render Test only on the client by using an useEffect to determine if it's a client.

import Test from "../components/Test.client";
import { useState, useEffect } from "react";
function Parent() {
  const [isClient, setIsClient] = useState(false);
  useEffect(() => {
    isClient(true);
  }, [

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@imrostom
Comment options

@empz
Comment options

@kjkent
Comment options

@jrnxf
Comment options

Answer selected by imrostom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants