Having trouble getting your React Native UI components to update after the state of your Redux store has changed? Your problem is likely related to the brave new world of ES6 and the Functional Programming Paradigm. Specifically, in your Redux reducers you need to make sure you are keeping everything “immutable”. The simplest way to fix this if the spread operator (…) isn’t working for you is to try wrapping values that you wish to copy in JSON.parse and JSON.stringify methods. I know it’s very ugly, but it is an extremely effective method for fixing issues with React, Redux, and UI components that are failing to sync with state changes in your Redux store. For example, take a look at the two reducers below. The first example shows a broken reducer from one of my applications. And the second example shows the same reducer after I fixed it using the method described above:
Quick little demonstration of how to server static HTML pages using Golang. This example assumes both your index.html and webserver.go files are in the same directory:
Need routes to other pages? Check out this example I have posted on GitHub: SimpleGolangWebServer
Need to serve up JSON instead of HTML? Check out this example by Tom Hudson: simple-json-api.go
This post is sort of just a bookmark for myself, as I know I will undoubtedly need to reference the React-Native/Redux boilerplate for years to come. However, maybe someone else out there on the internet will find this helpful as well! TLDR: Aligator.io has the best quickstart tutorial with all of the boilerplate code that you need to get up and running with Redux in a React-Native project.
Now for some more opinion and a quick rant: All of the boilerplate code that is necessary to get up and running with Redux is its biggest drawback. Personally, I hate boilerplate code. Maybe that’s because I’m a pretty messy and disorganized person, but I can’t stand having to write and learn tons and tons of boilerplate code just to get started with something. Take the Django web framework for instance. The first Python web-dev project I ever undertook I initially turned to Django after coming from a PHP background. But after 4 pages of “Getting Started” material I still had not gotten to “hello, world.” So I ended up ditching Django in favor of the much simpler Flask web framework, and haven’t looked back since.
With Redux I find myself in a similar predicament. I need some sort of state management for my React projects as the built in system just isn’t cutting it anymore, but is Redux really the best option? A much simpler solution is Unstated. So if you’ve made it this far in my post and are having similar feelings, I suggest checking out Unstated.
The only problem with Unstated is that employers are probably using Redux (or possibly MobX-State-Tree). So you kind of have to learn it, just because that’s what everyone seems to be using. In essence, I don’t think Redux is so bad. Actions, reducers, and a store. Pretty straight forward right? It sounds simple, but in practice it’s probably the most painful part of programming in React.
Having trouble running getting your React Native app to run? Haven’t worked on it in a month or two? Now you’re running into this error about debug.keystore not found? Fret not dear internet friend! Here are some solutions that may help.
I personally ran into this error after cloning a previous version of an app that I was working on from Github. Like you, I ended up trying many different things to fix this problem. However, I’m not sure if any of the steps I performed prior to stumbling upon a good solution were necessary. But just to make sure, I’m going to include some of the steps that I took before getting my app to work again in case any of these steps may be helpful or necessary to anyone else out there on the internet.
First I installed all of my node packages with npm…
$ cd MyAwesomeReactNativeApp
$ npm install
After installing all of my node dependencies I then attempted to run the app for the first time and ran into the error message described above. My first attempt at fixing the problem involved attempting to reinstall all of my native Android dependencies with gradle…
$ cd android
$ ./gradlew build --refresh-dependencies
$ ./gradlew clean
I’m not sure if this is ever necessary for Android like it is for iOS with cocoapods and pod install, but it is something I did, but it probably didn’t actually do anything and likely wasn’t necessary.
Next, I attempted to create a new debug.keystore file myself using the following terminal commands:
$ cd android/app
$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
Unfortunately this didn’t actually work! But what did work was importing my project into Android Studio, cleaning the build folder from within Android Studio, and then running the app on the built-in Android emulator instead of my actual Android device. Please note that I was prompted with an error message when running the app on the simulator that Android Studio wanted to delete the previous version of the app installed on my emulator, so please make sure to do this if your are prompted for something similar.
Also, please note that I deleted the old version of my app from my physical phone before attempting to run the app on my personal device as well. However, this was not sufficient to solve the problem. In conclusion, you need to make sure you delete any old versions of the app that were signed with old keys from your emulator or device AND then use Android Studio to clean your build folder and run the app. In my case, I believe Android Studio handled fixing all of the issues related to the mismatched debug.keystore files behind the scenes for me, so if you are stuck on this, I suggest you let Android Studio fix the problem for you as well.
Hope you found this blog post helpful.
P.S. This was the first time I worked on this particular app since publishing it on the Google Play Store. So signing the production release of the app was probably a big part of the problem as well. Whatever the exact cause, the steps above should fix the issue.
Was your app recently rejected from Apple’s App Store due to minimal functionality or content under guideline 4.2? You’re not alone! On this episode of Misadventures in Startups I talk about my own experience with the arbitrary and fickle nature of Apple’s App Store review process, and suggest a possible solution: Cross Platform Application Develop for Android, iOS, and the Web with ReactJS & React-Native. Are Google or Apple’s monopolistic policies over mobile application distribution getting in your way? Facebook Inc. has a tool for that.
Having trouble stripping newline characters from a string in Golang? The easy way I’ve found is to use strings.Replace. Also, make sure to see the “gotcha” involving runes below the example code. Sometimes you will need to change the “/n” character to the newline rune “/r/n”.
However, beware of this gotcha involving runes. I’m still a newbie Golang coder so I don’t fully understand all of the differences between strings, bytes, runes, and characters, but sometimes the code above will not work. Instead, of stripping the newline character “/n”, you’ll need to strip the newline rune “/r/n”. In this case, your code will look something like:
string_b = strings.Replace(string_b, "\r\n", "", -1)
“Ha! I hacked you!” the L337 haXX0r wizard snickers.
Just kidding dear internet friend! If you’ve noticed unusual traffic to your WordPress sites homepage that includes the HTTP GET request query parameters /?a=fetch&content=die(@md5(HelloThinkCMF)) there shouldn’t be anything to worry about as long as you are running the most recent version of WordPress.
But yes, apparently this is some sort of old WordPress exploit that doesn’t work anymore. Tonight I happened to notice unusual traffic with this pattern to my personal blog, so that’s how I heard about it. However, I think I’m going to get the last laugh, as I have a feeling this blog post is going to end up driving a ton of legitimate traffic to my blog.
So ha! I hacked you! L337 haXX0r wizard. Thanks for the traffic.
Trying to figure out how to include a question mark in your HTTP GET request query strings? Simply swap out the ‘?’ for ‘%3F’. For example, if you wanted to search DuckDuckGo for the following question:
“who won the superbowl?”
You could use use a URL that looks something like:
Notice, the spaces become ‘+’ symbols and the question mark becomes ‘%3F’. Hope you found this blog post helpful, and happy hacking my friend!
Customer Service & Support Contact Information
Contact Name: Christopher Pedersen
Contact Phone Number: +1 (469) 261-0727
Contact Email: chrispedatx [at] gmail.com
Your privacy is important to me. It is my (Christopher Pedersen) policy to respect your privacy regarding any information I may collect from you on my app, “Happening Now…”.
I only ask for personal information when we truly need it to provide a service to you. I collect it by fair and lawful means, with your knowledge and consent. I also let you know why I am collecting it and how it will be used.
I only retain collected information for as long as necessary to provide you with your requested service. What data I store, I will protect within commercially acceptable means to prevent loss and theft, as well as unauthorized access, disclosure, copying, use or modification.
I don’t share any personally identifying information publicly or with third-parties, except when required to by law.
My app may link to external sites that I do not operate. Please be aware that I have no control over the content and practices of these sites, and cannot accept responsibility or liability for their respective privacy policies.
You are free to refuse our request for your personal information, with the understanding that I may be unable to provide you with some of your desired services.
Your continued use of my website will be regarded as acceptance of our practices around privacy and personal information. If you have any questions about how I handle user data and personal information, feel free to contact me (firstname.lastname@example.org).
This policy is effective as of 01 February 2020.