Skip to content

Errors in render and preview #301

@dougg0k

Description

@dougg0k

Hi,

I've just found your library, seems very nice as alternative to older solutions like handlebars. But a few problems appeared, not sure why.

Firstly, if I try to import a tsx template file into a nodejs ts file. It is turned into a typescript type import.

Then the render gives an error await render(<Template data={data} />); Template refers to a value, but is being used as a type here. Did you mean typeof Template ? Which seems fine due to the import issue.

I tried to add "jsx": "react", to tsconfig.json but it didnt solve the issue.


Secondly, the template file, was complaining about the lack of reactjs being included there, where in your docs, you dont mention that it is needed. Maybe I missed something.

I then add reactjs and import it into the file import React from "react";.

Then I tried to preview the template, before I had added the reactjs as dependency. I got another error.

...
[20:06:32]  info  Starting build...
...                                          
ReferenceError: React is not defined

After adding the dependency it built. But when opening the page in the browser, the screen is empty with this error in the console. Uncaught TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher')

Can you help tell what I have done wrong? And why your docs do not mention certain things?

Does it expect to be in a frontend project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions