[enter image description here](https://i.stack.imgur.com/lON9e.png)
I'm writing code for a task in a react course and after the file is saved it simply changes what I wrote and a bunch of errors appear and o I don't know why. The first pic is what I wrote, and the second one what happened after I saved the file. Can someone tell me why this is happening?
This never happened to any other code I wrote before.
Your VS Code settings are probably set to run a linter (ESLint maybe?) when you save your file. You can check your settings in the VS Code workspace settings: https://code.visualstudio.com/docs/getstarted/settings. If you hover over the red squiggly lines it will hint at the errors in your code.
It's been awhile since I've worked in React, but I think you might need to wrap your return in a string literal (backticks: ``). You also might want to use Typescript or JSX with React.
You can also post a sample on Stackblitz https://stackblitz.com/ if you want more help.
Related
I am using react-native-calendar-picker from github to use a calendar in my app. The problem it's that everytime I run it, I get some warnings like:
As seen there, there's something about node_modules\react-native-calendar-picker\CalendarPicker\DaysGridView.js , and there are 4 warning, with rows 254,255,256 and 248. Going to that file, I found that those lines are:
So, the problems seems to be somewhere at selectedRangeStartStyle, selectedDayStyle and selectetRangeStyle which I have setted in my componenet with #XXXXXX, as hex color codes. Any help would be appreciated, thanks!
I am also getting the same warning because of those lines. It was a change introduced by this commit https://github.com/stephy/CalendarPicker/commit/081a07f6c95fc178d17295ef0cd3f68f2b7d117f to fix this issue https://github.com/stephy/CalendarPicker/issues/246
Reverting the changes locally on the file stopped the error from popping up in my console, but that is just a quick workaround i found for now only.
I am using VS Code on a Mac to write ReactJS, however I find that I could not save my code. If I use command and s to save, then the JSX will be a mess, just like shown in the picture:
enter image description here
So how could I solve it? Thank you
I think your code is being saved, but that your code formatting is messing-up your code.
Hit the following combination : Shift+Command+P
This will open a menu on top. Inside that menu type Format Document With..., and select it. It will allow you to format your code with a different auto-format tool. Choose the one that is appropriate for your code i.e. Prettier.
Attached is an image of what I am receiving when I try to bundle my project for production. I am receiving a Unexpected token name <<Object>>, expected punc <<,>> message as shown in the image.
Terminal output of error
Not sure what the issue is but I have tried to use uglify-es and uglify-js and get the same error. I even attempted to make a simple app using es6+ code to see if uglify-js worked and it did. So some of the older threads on the internet mentioning that uglify-js won't handle es6+ code might be irrelevant now. I also read somewhere that the newest version (3.x) does support it but haven't been able to confirm that.
I would love to show some code but not sure what relevant piece of code I need to show. As per the image it also mentions the line, col, pos etc... but the code on that line does not start at the col number mentioned.
I will definitely update this post as I investigate but any tips or ideas would be great!
So the issue is now resolved after some thorough research. It looks like the line 1665 I was looking at in my non-optimised bundle app.js was not what I needed to look at (obvious since the column index was way off).
So instead I decided to output the bundle generated code that FuseBox was working on and it was in-fact different. This is the line I added in node_modules/fuse-box/quantum/plugin/BundleWriter.js inside the uglifyBundle function to output the content so I could read it clearly.
fs.writeFile('bundle.txt', bundle.generatedCode);
The output in bundle.txt that was the issue and my actual TypeScript code is shown here:
// bundle.txt line 1665
this.wholesalerSettings = [object Object]
// actual project code
constructor() {
this.wholesalerSettings = process.env.WHOLESALERSETTINGS;
this.API = this.setHostUrl();
}
So I took a look in my fuse.ts file and noticed I was not parsing the json object correctly.
public get wholesalerSettings()
{
const wholesaler = require(`./src/~/wholesalers/${this.wholesaler}/config.json`);
return JSON.stringify(wholesaler);
}
// then down in the environment plugin
EnvPlugin({
WHOLESALERSETTINGS: this.wholesalerSettings,
IMAGE_PATH: this.imagePath
}),
Once I parsed the object correctly with JSON.stringify it worked perfectly as process.env.WHOLESALERSETTINGS was now a JSON string instead of an Object.
First time I really dealt with devops stuff but was fun and at the same time highly stressful. I guess the main thing I learned is when you are dealing with tooling and third party tools (FuseBox uses uglify-js) then you need to take a closer look at the input that is being given to that tool rather than the output like I was at first.
UglifyJS says it sees Object where it's expecting a ,, so we can infer:
The code you wrote (or generated by some other tool right before uglifyJS processes it, e.g. babel? Though you probably don't use babel since your uglifyJS deals with es6 directly) is "Object" where the error occurs.
It's expecting a ,, so the error is occuring at some place like multiple variable declaration, let foo, bar, or object/array definition, [1, 2] {foo: 1, bar: 2}
This question already has answers here:
Xcode 4: Creating a UIView xib, not properly connecting
(33 answers)
Closed 9 years ago.
Could not insert new outlet connection: Could not find any information for the class and not showing any class named "ViewController"
Solutions I have done :
- Restarted XCode
- Restarted System
- Deleted the Deriveddata contents from /Library/developer/xcode
But nothing worked for me
Here is the screenshot for the error
I got the same problem as you today... I think this is a bug of Xcode, below is the way to fix the issue:
Close the project you are working on with.
Delete your project's【DerivedData】folder. (This folder may inside your project's folder, or inside ~/Library/Developer/Xcode/DerivedData/(your project)/ ) or somewhere else that was setup by you.
restart your project.
After these steps, the problem should be solved. And from my experience, these steps can solve many Xcode problems, so if you got some problem with Xcode again, try these steps first.
Removing(removing reference, not deleting) and then adding the appropriate file(the file of class you want to add the outlet to) is actually enough.
Edit 1 I found that after unchecking (in XCode 6.3.1) I had to wait a few seconds for the Indexing to appear and complete in the project name box. Same for the way backwards. This increased chances to fix the issue in almost all (but not all) cases.
Edit 2
Removing reference means that You do not delete the file completely but just remove it from the project (it still exist in the folder of your project, you add it later).
That's most often a problem of file indexing.
To fix it try to clean your target and if this doesn't work, go to your Derived Datafolder and delete your application there.
This will force xCode to reindex the files
Just got the same issue on Xcode 4.6.2.
Tried solutions presented in different answers/comments, but it still didn't work.
Then all I did was to just:
save all my work;
just quit Xcode & load it again;
then I was able to insert the new outlet connection successfully.
Hope this will save some time/frustration for somebody else.
Personally, I had the same problem: "could not insert new outlet connection" AND when I was starting typing something like "UI..." XCode wasn't doing anything.
I searched for answers, I tried several things... but it was just an unchecked box. When I was creating a new class, XCode unchecked the box linking the class to the project (I guess).
I can't post a screen shot because I don't have 10 reputations but when you create your class, XCode asks you where you want to save it. Down the finder window, you have 'Targets' and two boxes: 'YouProjectName' and 'YouProjectNameTests'. You should check the first one (at least).
Hope this will help. I saw different discussions about the subject.
I recently came across this problem. I soon realized that the cause had been my own doing. I had previously disabled XCode indexing (which used to take forever & eat up my RAM), using the below code in a terminal window:
defaults write com.apple.dt.XCode IDEIndexDisable 1
To revert XCode to its default state, i used the following line in a terminal window:
defaults write com.apple.dt.XCode IDEIndexDisable 0
Voila! All's well again..
If you've imported the Class into your Xcode Project you have to manually add the Class (.m file) to your 'Compile Sources'.
Select project icon > TARGETS > Build Phases > Compile Sources
Click the + button and add your *.m file.
Finally I did it by removing the xcode completely from my mac and reinstall the xocde.dmg file and then install MobileDevice.pkg and MobileDeviceDevelopment.pkg residing on /Applications/Xcode.app/Contents/Resources/Packages
make sure that your source have had been included in the "Build Phases" place.
This do fix my problem. But I think Xcode is still really buggy and annoying.
I am currently trying to find the face in a particular image.I am following
this website :
http://www.cognotics.com/opencv/servo_2007_series/part_2/index.html.
I am following the code in this page.But i dont seem to see the option/part
of the code to include my image[ am i supposed to change the argv[1] part in the code to my own image inorder to read my image]
Can someone guide me?
Or is there any better face detection code available?
Thanks
You are supposed to pass your picture as a command line argument.