npx react-native init AwesomeProject
Create .tsx project by default. I need to create .js project.
Do you know the solution?
react native is shifting more and more to typescript to make dev easier - please also see the official blog and last posts
You can though easily get it back to js by changing the tsx to js and deleting the additional typescript content, normally takes less than 5 mins.
Related
I have a React project created using JS only. react-scripts version: 5.0.0.
Now, I want to start using TS in the project (and slowly migrate the project overtime). It's quite a huge project now and everything can't be migrated all at once. Thus I want to start adding new components (or pages) written in typescript and also gradually work on migrating the existing javascript files to typescript.
I googled for solution, and answers suggested to create a new TS project and copy the files to the new project after renaming them to .ts or .tsx. But in our case, it's not very feasible.
Other answers suggested ejecting. But I want to use that if all other ways fail.
Are there any other ways I can do this? If we could somehow allow to have both the type of files and then could disable this in future when all the files have been migrated.
Currently trying to import a .tsx file in .js says module not found. I tried the solution from this post. But still has the same error.
I am kinda new to front web development, but there is one interesting question for me.
I got a simple vanila html+css+js website, in which I want to integrate a few actions (profile page, custom e-commerce, checkout, etc) using React.
As I followed this tutorial (Add React in One Minute),
I had successfully "inserted" react component into the webpage. But the normal reactjs applications are able to use installed libraries, use props to pass data.
So, basically, the question is how to run this webpage the way that react will be able to handle libraries installation (common npm i example) in order to be able to import them and work like with normal react application created by npx create-react-app my-app
You could use libraries via a CDN link, the same way you added React via a script-tag to your site. Ultimately i think you're looking for the developer experience one gets while using JSX-syntax and this would require you to rewrite your exitsing app, achieved trough setting up a node project with your mentioned command npx create-react-app <app-name>.
JSX must be compiled to regular JavaScript so that browsers can interpret them correctly, much like you would compile a C++ program to a binary file.
I am implementing vue-monaco plugin inside Laravel application using Vue.
The steps are rather easy, I install the vue-monaco like:
npm install vue-monaco
Then in my Vue file I import the monaco editor like:
import MonacoEditor from 'vue-monaco'
I don't even use it, just import it and then run npm run watch. This result in npm creating exactly 63 files in my public folder, like in the image below (first 15 are shown, 63 are being created).
Why does this happen and how can I bypass it?
vue-monaco is basically a VScode in your webview, right ? If it's the case, it's probably creating some configuration files for it to work and this is totally normal.
What's the content of those files and the content of your package.json (npm run watch) ?
If you want to custom some options for this plugin, it looks like that you will need to dive into those settings: https://microsoft.github.io/monaco-editor/api/modules/monaco.editor.html#create and pass it as props to vue-monaco (this info is taken from the doc itself).
Otherwise, creating a simple vue project can help debug things too IMO, see if the files are created in public too or if it's more of a laravel configuration issue. Then, you could maybe try the github issue of the main JS project: https://github.com/microsoft/monaco-editor/issues?q=is%3Aissue
I am working on a React Project and have a bunch of tsx files that I want to convert as use as javascript for my project. How should I do that?
I am working on a React Project and have a bunch of tsx files that I want to convert as use as javascript for my project. How should I do that
You can use the typescript compiler e.g.
npx -p typescript tsc somefile.tsx
Ciao, while the web is full of guide on how to translate React Javascript into Typescript, I don't found any reverse guide (so strange...).
Anyway, I had same problem some time ago and I found useful get one of those guide JS => TS for React and read backwards. For example, I used this guide. When he said "JavaScript looks like that so you can translate this into Typescript in this way..." I did the contrary (and it worked!). Of course you can skip all the dependencies part.
Try and let us know.
In all the articles that explain how to use create-react-app with electron (eg : https://www.codementor.io/randyfindley/how-to-build-an-electron-app-using-create-react-app-and-electron-builder-ss1k0sfer ) , they mention that electron.js file should be placed within public folder.
I want to have typescript definitions for this electron.js too (since i am using typescript for the react app also). How do I do this ?
I have spent quite a bit of time working on an electron project as well as creating a starter kit for using Electron + TypeScript (very strict) + Create React App (non-ejected). I think you might find it useful as a starting point, even though there might be some additional tooling that you might not need.
Check out the electron branch of Foldable for more details. Of particular interest would be src/electron.ts, package.json and the public dir.
To quickly give you some additional points that might be useful in your question:
One can configure the entry script for Electron in your package.json under "main"
You will need to use TSC or another typescript compiler to handle the "main-thread" or node portion of Electron. This is separate from CRA. Alternatively you can use plain javascript for a simpler setup.
The only thing in my public folder is the html file minus the javascript imports (because they are injected automatically)