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

Cannot read property 'createElement' of undefined #185

Closed
KerryRitter opened this issue Jan 28, 2022 · 1 comment
Closed

Cannot read property 'createElement' of undefined #185

KerryRitter opened this issue Jan 28, 2022 · 1 comment

Comments

@KerryRitter
Copy link

I was trying to spin up a demo based on the docs and I ran into the following error:

[Nest] 840  - 01/28/2022, 7:53:31 AM   ERROR [ExceptionsHandler] Cannot read property 'createElement' of undefined
TypeError: Cannot read property 'createElement' of undefined
    at MyView (/home/ritte/workspaces/liftoffjs2/src/views/index.tsx:9:3)

Here is the code I was using:

// views/index.tsx

import React, { ReactElement } from "react";

export interface MyViewProps {
  name: string;
  title: string;
}

const MyView = ({ name, ...props }: MyViewProps): ReactElement => (
  <div>Hello {name}</div>
);

export default MyView;

I converted to this code, and it resolved the error. Note the import.

// views/index.tsx

import * as React from "react";

export interface MyViewProps {
  name: string;
  title: string;
}

const MyView = ({ name, ...props }: MyViewProps): React.ReactElement => (
  <div>Hello {name}</div>
);

export default MyView;

Not sure if there's a change in the React version, or if this is a documentation bug.

@pmb0
Copy link
Owner

pmb0 commented Mar 12, 2023

This seems to be an issue with your typescript setup

@pmb0 pmb0 closed this as completed Mar 12, 2023
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

2 participants