-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on load image on React-native: Unexpected character #6691
Comments
Get the same error but only when overwriting an image already loaded and cmd-r is pressed. To resolve the issue temporarily it seems the image must be re-exported / overwritten and then a 2nd cmd-r to reload results in clearing the error message. Happens regularly at the moment for myself at least. Haven't had time to research further. |
Seems related to image map as noted here in this issue enzymejs/enzyme#253 |
Other potentials ( unlikely related to image map after all ): |
Same problem, fixed by re-exporting image as @seanfuture said |
Restarting the packager fix it too |
@facebook-github-bot answered |
Closing this issue as @dsibiski says the question asked has been answered. Please help us by asking questions on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only. |
FYI - StackOverflow link: http://stackoverflow.com/questions/36252381/error-on-load-image-on-react-native-unexpected-character/36289632#36289632 .. Don't believe this issue should have been closed as the above mentioned "fixes" aren't really fixes - Instead they're workarounds. Error still comes up often and a full restart of the packager is needed. Most definitely a prevalent and serious bug in the packager. Taken a brief look, but packager code doesn't immediately reveal the cause although my suspicion is that Node.js is trying to process the file / file change as an asset. |
I too faced the same error. After a lot of trying, I restarted the packager, and the app picked up the image. So the solution is: Restart the packager. Hope this helps. |
I know this is going sound pretty weird, but I'm going to add this comment in case anybody else gets here. I created a index.ios.js file by copying a simple sample from an internet example (actually something at https://rnplay.org) I kept getting "unexpected character" errors. I'm using Atom.io as my script tool. I was thinking perhaps I had an encoding issue with the wrong character set. I've confirmed I'm using UTF-8 So I was using the (left/right) arrow keys on my keyboard, and I notice the cursor would stop moving for two keyboard arrow pushes, right at the location identified in my Emulator Red Screen of Disaster. It was like there were two invisible characters in my code. I played with this for a pretty long time to confirm. I was able to highlight the "hidden" characters and delete them. After deletion, the new code works great. Bizarre. Not sure what was there. (Note: I copied the Slider Example Code from https://rnplay.org/apps/5FsfPA and I used a "Select All" and Command-C to do the copying and Command-V to paste... if anybody wants to repeat the experiment) And yes, I know how silly this sounds. Perhaps others have hit the same roadbump? |
stop the server and execute |
@duzliang Stopping and starting the server did get rid of the error message, but Im getting a blank screen now! |
the packager should not require this though -- this is a bug, and even though there's a workaround, it should be fixed. this isn't a SO type question, it's a "please fix the packager" |
Still having this issue. Happened in various occasions, most reliably when I open an image being used in the react native app with preview (hit space bar in finder) on OSX. |
+1 |
Switching react-native from 40 to 38 helped, i don't think this should have happen |
Another suggestion is to |
started seeing this today after updating to RN v0.40.0. Tried all the workarounds mentioned in this thread but no luck 😞 |
I have this issue as well. Turns out it is because I have spaces in the project path:
Running |
I had this same error, myfile.png: Unexpected character '�' (1:0)
After I need re export my file. |
@fdb I do not have spaces in my project path and still experience this issue. |
@fdb that seems to be the case for me as well. |
@woshi82 I also have |
I had a |
I have no special chaecters in my path and it happens to me any time I make a change to the image and re-save it. |
This work for me sorry for my bad English |
Not using dropbox, don't have a Working on IOS. |
as suggested by many here; restarted the entire process environment and now everything works. However, this is a BUG that NEEDS FIXING without any workarounds if this is going to make it to the real world. Going to SO with a question like this brings out the arrogant admins where they take GREAT pleasure telling you how to ask intelligent questions and what is an intelligent question is. To them, this IS NOT and intelligent question so no answer is given. I speak from frustrating experiences with SO, so I've learned to read, not speak. The problem with this type of bug is that when you're deep in the dev cycle and you get this bug, some of us forget about the bug and end up wasting an enormous amount of time troubleshooting. when it happens more that once, it makes you feel like an idiot for NOT remembering what the solution/workaround is! BAD! |
Check that if your project path has a special symbol, like '+'. |
Restart of packager works, but is a bit annoying :-) |
Just got this on 0.44.2. my path has '-' not sure if it's the reason. Restarting the packager fixed. |
I have a same problem, because my image's name has '-','+','_'. the solution is try react-native link or restart packager. |
I have very easy fix for the problem that works perfectly for me. I remove the problematic image from the assets folder and add it again. And the red screen is gone. Just drag & drop. Restart is not needed. |
Removing spaces and parenthesis from my path fixed that issue for me too. |
Hello there, I also get this issue! I'm using Typescript with : Let me know if you find something, cause this issue turn me crazy.. |
I solved(!?) this problem by creating a copy of the image and replacing the original one, then renamed the image. This indeed is a weird bug, your photo at once becomes useless. |
Closing the server and restarting it works just fine. |
@sylvainbaronnet thanks it's working for me 👍 |
@ShubhamOjha: I don't think this is really a solution. One nice thing about react native is the hot reloading feature. Which is made completely useless if you use images in your project that change during development. |
faced the same problem and solved by renaming the .png to .jpg and it works. |
same problem here, any process? |
Same problem, but nothing worked. Killed and restarted the packager, replaced the image... Same unexpected character red screen. Really frustrating.. Newbie dev here :) |
This is fixed for the next release of react-native, where we have many HMR improvements. cc @grabbou can tell you when that goes out but in your current version of react-native it isn't magically going to be fixed from one minute to the next. |
Try terminate your terminal server and react-native run-android / ios 🗡 |
As @danilags says
|
tl;dr Always use I had this same issue. Using an uppercase |
foobar.JPG causes this really annoying error .. lotta people wasted a lot of time .. not a confidence booster |
react-native-cli: 0.1.10
react-native: 0.22.2
SO Mobile: Android
SO: Mac
I'm try display a image on a component on React-native, but I don't know why this error happens...
Example of code:
The text was updated successfully, but these errors were encountered: