Click to Download .ICS File - reactjs

In my React project, I have a calendar .ics file in my local folders and want the user to download once they click a button so I'm providing the path to the .ics file in that button. However, I'm getting this error:
"Module parse failed: Unexpected token (4:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file."
How do I simply have users click a button to download an .ics file?

Introduction
I was going to just add a comment to your answer, since I don't have a definitive answer for your question, but it turns out that I need a minimum of 50 reputation, so...
I'm not sure if provided enough information for your problem, but I'll answer based on what could understand from your statements.
The Problem
[...] However, I'm getting this error:
"Module parse failed: Unexpected token (4:6) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file."
I don't know what module bundler your are using, but it seems that your bundler can't recognize .ics files. Hence, you need to declare the type of file. Check your module bundler configuration files and add the required support to the aforesaid extension. If you're using Webpack, for example, change the rules attribute of your webpack.config document adding a new rule, notice that, in this case, you'll need to provide a loader.
I hope this helps. This is my first answer here on StackOverflow, sorry if I misunderstood anything or something simillar.

Related

Imposible to debug one create-react-app, I only see the bundle.js errors

I am launching the create-react-app and if throws me one error, but if I see it on Chrome dev tools it refers to one line in the bundle.js that is generated by webpack by default in create-react-app... So it's not useful for debuging.
Are there any way of that Google Chrome Dev Tools show me the error link line to the original .js file and not to the bundle.js one?
Now I only see this error:
This particular warning will lead you only as far as react-dom.development.js, which is equally useless in my opinion. But if you really want to know what happened, my guess is that you started the production server instead of development.
Either way, the warning is still very revealing and might help you discover the problem even without knowing the exact file. It's telling you that you set the c prop to a boolean on a <div> element (you can know this from the "at div" part of your warning), which is unsupported. This is was most likely a typo or hitting the key accidentally without wanting to type anything, so you might have something like <div c> somewhere.
You can search for this in your project using a regex like \bc\b, or search for a string like c={ in case your mistake was more deliberate.

Permanently resolve Unable to watch for file changes in this large workspace

To resolve this issue I got there to the link provided by vscode
https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc
Ok, this, corrects the error, But when I restart the Linux and again open my React project,
I get the Same error.
max_user_watches file again gets the value of 8192 as no. of max files.
My react server is not starting due to this issue.
Then I again follow the same step of the link provided, this sometimes gets frustrating.
Any permanent Help I could get from you.
A workaround:
Just disable this built-in extension: TypeScript and JavaScript Language Features

Is there a way to render a TSX file when loading http://localhost:8080/test?

I'm really a newbie in front-end development. I'm currently involved in a project that does front-end development. I hope I can explain this clearly.
Whenever I call http://localhost:8080/test, it is loaded by page1.jsp.
Now I would like to load a TSX file instead of a JSP. I tried changing my <welcome-file> from page1.jsp to html/js/page2.tsx in web.xml but I don't know why it is not working.
What happened is that a download file window will pop up instead of loading http://localhost:8080/test.
I placed the TSX file in the html/js directory because that's where the package for Typescript and React is located. By the way, the TSX file I'm talking about is a React component that uses Typescript.
Is it possible to configure the web.xml to render the TSX file? If not, is there any other way for me to load it?
Is web.xml still important if I want to load a TSX file?
No, for several reasons:
A .jsp is a "Java server page". You are probably running an application server like Tomcat (I haven't done that in fifteen years or so, so bear with me). It is compiled into a Servlet, which then runs to produce your page as output. Your .tsx file doesn't fit in that process.
Your application server probably has a directory somewhere where you can put static files that don't need to be run on the server side; see if you have a "WebContent" directory or so. In it you can place pure HTML files, Javascript files, fixed images and so on.
But if you put your TSX file there, your browser still won't be able to use it: browsers don't understand Typescript. Typescript needs to be compiled into Javascript, and if you put the resulting .js file there, then a HTML file could use it (with a tag), and that would work.
But your file isn't only Typescript, it's a tsx -- it probably also contains JSX, which also needs to be translated to Javascript.
There are also dependencies, like React, that you'll also need to download in your HTML.
On the whole this is what a bundler like Webpack is for (if you used create-react-app, for instance, you'll get a working Webpack configuration from the start). It can create a "bundle.js" containing all the Javascript needed in one file, including all the dependencies and all your TSX code compiled to Javascript.
Place that in a WebContent or similar directory, call that from a tag in some HTML file -- and you'll hopefully get a nice error message in the console that'll lead you to the first thing I forgot to mention :-)

how do I configure a codenameone project to install on external storage in Android

I am trying to get my codenameone application to install to external storage, so I do not need root permissions to debug what is writes to storage, as it does not work on Android, even if it does in the simulator.
First I assumed just having codename1.arg.android.installLocation=preferExternal in codenameone_settings.properties would do just that, but the application still installs to internal storage even after changing that installLocation to preferExternal from auto.
So I thought perhaps it needs quotes for the preferExternal, and proceeded to give them (=\"preferExternal\") - this gives a manifest build error on the build server, which shows the manifest with double quotes, so the original was the correct form.
From the error report, I saw that
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:required="false" />
so I thought perhaps this needs to be required for the install to external storage to actually be possible. I tried adding codename1.arg.android.permission.WRITE_EXTERNAL_STORAGE=true to the properties file like the documentation would suggest, but that fails in manifest merge:
Merging result: ERROR
/tmp/build6786351350686020379xxx/happy2/src/main/AndroidManifest.xml:48:7-69 Error:
Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:49:5-81 duplicated with element declared at AndroidManifest.xml:45:5-106
/tmp/build6786351350686020379xxx/happy2/src/main/AndroidManifest.xml Error:
Validation failed, exiting
Ok, so I thought that is always included, and thus I just need to change the required setting to true, and followed what the documentation says by adding codename1.arg.android.permission.WRITE_EXTERNAL_STORAGE.required=true to the properties. This builds, but the actual permission is not set to android:required="true", but remains false.
Using android.xpermissions tag to insert the wanted line <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:required="true" /> does insert it to the manifest, but manifest builder gives and error since the default false line will still be there too:
Merging result: ERROR
/tmp/build5902390972256151175xxx/happy2/src/main/AndroidManifest.xml:48:3-103 Error:
Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:48:3-103 duplicated with element declared at AndroidManifest.xml:45:5-106
/tmp/build5902390972256151175xxx/happy2/src/main/AndroidManifest.xml Error:
Validation failed, exiting
So the question remains, how do I configure a codenameone project to install on external storage in Android?
See this android:installLocation="preferExternal" not working
The gist is that parts of your app will always install in the hidden area and storage will probably go there.
If you want to write stuff to the SD card you can do that with the FileSystemStorage API which allows you to write to arbitrary roots. You can detect the SDCard root and just write there. I would suggest debugging in the simulator though where you can see the content of storage easily in the .cn1 directory.

jTwitter, oAuth, and Google App Engine. NoClassDefFoundError

I'm trying to use jTwitter to get an oauth instance to twitter with my consumer key/secret and access token/secret. This is well documented in the javadoc here. I have downloaded signpost, signpost-jetty, and the jtwitter library, but after deploying and running the servlet, I get a error java.lang.NoClassDefFoundError: winterwell/jtwitter/OAuthSignpostClient Eclipse isn't complaining about the class not being there, because it is there-- I can see it in the JAR file itself, which is in my project. So, I said forget it, I'll try out OAuthScribeClient instead, but this generated a VERY SIMILAR ERROR java.lang.NoClassDefFoundError: org/scribe/oauth/Token This one confuses me even further because I have the following code in my java file, and it compiles without error or warning:
import org.scribe.oauth.Token;
Token token = new Token("myaccesstokeninfo", "accesstokensecret");
Clearly, I'm missing something very fundamental, but I am at an absolute loss as to what it may be. Thanks.
Usually "NoClassDefFoundError" happens when you forget to copy all jar-files to your "/war/WEB-INF/lib" directory, so those libs will be unavailable from server-side.
Xo4yHaMope is probably right.
If you're working from Eclipse but running using a web container, then your runtime classpath might be different from your project classpath - which can cause this error.
In order to complete Ben Winters answer what I actually did and worked is add the jar in
the libs folder within the project
see also here about folder hierarchy.
When you do this eclipse will normally add the jar to the android dependencies before launching the application. What I realise is that adding a jar in the build path will make classes available only during the build

Resources