ReactJS: Refers to a value, but is being used as a type here

I was a little confused the other day when I began receiving an error that seemed to be about ReactJS, however, I was writing a non-react typescript file at the time.

Error: “Refers to a value, but is being used as a type here”

What I eventually realised, was that while it wasn’t a React component file, it was using one. I’d decided that it was the file in which I would add a root node to the DOM to attach the React app too.

my-file.ts

import MyReactApp from 'my-react-app';

const rootEl = bodyEl.createEl("div");
this.root = createRoot(rootEl);
this.root.render(
    <MyReactApp/>
);

The problem

I thought that all of my React setup only applied from within the React component, but in order for the code parser to know what to do with JSX like <MyReactApp/>, this file also needed to be a .tsx, not just a ts.

That was the only issue for me that caused this error. The file was an embed for an Obsidian plugin (You can ignore that if you’re not familiar), so it wasn’t a tsx file to start.


This stack overflow post helped me along the way.

Thanks…

I also dissect and speculate on design and development.
Digging into subtle details and implications, and exploring broad perspectives and potential paradigm shifts.
Check out my conceptual articles on Substack or find my latest below.


You can also find me on Threads, Bluesky, Mastodon, or xTwitter for more diverse posts about ongoing projects.

My latest articles

Staging XR scenes (Keep doing your crappy little drawings)

Some people create beautiful perspective illustrations to visualise and storyboard their virtual reality designs And it’s tempting to think you’re not a strong designer if you’re not doing that too…

Focal point blocking for XR media

Planning out a linear VR experience requires thinking about where the viewers attention might be. Thinking about the focal points…

Designing immersive experiences

In traditional cinema, TV, or even the more modern phone screen, there’s limited screen real-estate. But removing that limitation creates a design problem…

The future is not prompt engineered

Let’s not pretend the importance of prompt engineering is ubiquitous. The most prevalent power of generative AI is in the way it adapts to us, not the other way around…

The typography of dates, times, & filenames

A deep dive into carefully considered date formatting, line length and general typography attributes of filenames…

Loosening the Shackles of Rapid Authoring Tools

Rapid authoring tools like Articulate Storyline and Evolve Authoring make sharing projects possible across a team of non-programmers, but your design must often adapted to the limited range of possibilities the tool allows…
Bluesky
Threads
Twitter / X
Mastodon
Instagram


Author:

Date:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.