#How can I use react with Typescript Electron. How can I render it.
1 messages · Page 1 of 1 (latest)
That is what they call it by default. "App" just doesn't seem to fit the bill. Anyways, it dosen't import app.tsx at all. So how is it accessing this information.
I just forgot to import it but you need to import it of course
you can name the component as you want
but keep in mind that the convention is PascalCase for a React component's name (and its file name)
and this will render it.
For certain componets don't you have to use React.Componenet or React.FC
Only if you need componentDidCatch
Class components is the old way, now you can use functionnal components with hooks
any actual documentation?
Most of them are functions instead of a const
that the same thing
const myFunc = () => "Hello";
function myFunc() { return "Hello"; }
Maybe you should take a JS course before learning React
I know how to use js.
Well, now you know one more thing
Does my renderer have to be tsx.
No
Alright so just the componenets
you don't even need the "x" part for anything
But if you use it then it's when your file contains JSX
Mhm.
Well I think I have to use it for my renderer file sense webstorm dosen't like ts for <App />
what's the error on domNode?
TS2345: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'Element | DocumentFragment'. Type 'null' is not assignable to type 'Element | DocumentFragment'.
do you have a div with the id root?
watcha mean
yes
with the id root?
Yes.
The renderer.tsx is not detecting the html to see if its got it in there.
huh
Can you explain?
explain typescript?
No.
Ah ah, the joy of TypeScript
Just the error.
error explain
you just skip error
I think I know what it is
dont think so
its domNode
or wait no. Its actually createRoot
I think createRoot passes 2 param.
only one
Nope
2nd one is optional
Oh
Alright, anyways do I need to register the renderer anywhere or should it load it by default.
In electron.
Have you read the docs?
I built it
via browserwindow
Have you configured webpack correctly?
This uses webpack. oopsies
Honestly webpack is kinda weird to me. Is there any other way
Again not very found of using webpack
I'm going to have a few html pages and then they are just going to rename them to diff names and its just annoying to setup in general :/
Typescript react requires the use of .tsx file extension and telling typescript Compiler via jsx flag (?) In tsconfig that it has to compile those as jsx
In generel react is sadly rather a pure js framework with no real typescript support build in. So adding typescript on top of it can feel cumbersome. What helped me was this page https://react-typescript-cheatsheet.netlify.app/docs/basic/setup/
Not the setup part but every other subpage which gives examples of how to add typescript to hooks etc
I guess?
Alright. Well, how can I make react work cus it seems this is not helping.
Have you ever used react before? If no. Give create react app a try
I have the feeling that this is not about Electron but about learning those frameworks first
I have not but then again.