Redux v3.2.0 Released

React Redux

So it’s been a busy couple of days for the Redux team. They recently released v3.1.6 with the following updates:

  • subscribe() now throws a descriptive error when the listener argument is not a function
  • bindActionCreators() now ignores anything but functions on the input object

And then they fast-followed with patch v3.1.7 with the following updates:

  • Fix an issue with setInterval unavailable in certain environments
  • Performance and memory usage optimizations
  • Slightly more aggressive minification

And just today, they released v.3.2.0 bumping the minor version with the following updates:

  • isPlainObject that we use internally is now outsourced to Lodash 4.1. Note that this does not mean we depend on Lodash itself. We only use a tiny module from it. We will be able to reuse the same module in React Redux.

Again, I’ve said it before, but I’m really impressed and glad to see how active the Redux project is. Kudos to the team for being so active and constantly making updates.

 

Redux v3.1.5 Released

New version of Redux has been released – Redux v3.1.5 is a minor update with the following changes:

  • replaceReducer() now throws a meaningful error rather than crashes if argument is not a function

It’s always nice when an error is handled correctly rather than just crashing. I am pretty impressed by the frequent updates for Redux. It’s really amazing to see something that originated from a presentation turn into a popular open source project that is actively maintained.

React v0.14.7 Released

Facebook React

Looks like we have another release from the React team over at Facebook. React v0.14.7 is now available. Updates for the release include:

  • Fixed bug with <option> tag when using dangerouslySetInnerHTML
  • Fixed memory leak in synthetic event system
  • Fixed bug with calling setState in componentWillMount when using shallow rendering

Good stuff here and definitely worth an update if you haven’t updated in a while. I saw a huge performance improvement after not upgrading for a few months. Rendering on the server was faster, less memory being consumed and fewer warning in my logs. It shows that I should probably stay on top of new releases and keep my packages up-to-date. Cheers.

Setting up analytics for your React Native app

React Native Analytics

When I finally got my iOS app (Sprinkles) to a good point and wanted to start testing it on real devices, I did a bunch of research and looked at things like TestFlight but eventually decided on Fabric because of the added analytics support and the idea of cross-platform support if I decided to also use it for Android as well (and this was also around the time React Native rolled out support for Android). Another positive for Fabric was the installation process. Once you created an account, you install Fabric and it walks you through how to add Fabric to your existing projects. They made it pretty simple and the instructions were really easy to follow. And once installed, I could then build the app and distribute it to people by email and it also tracked some basic analytics like number of active users, number of session and average session length. And it also tracked exceptions/errors and provides a stack-trace if available. For example:

Thread : Crashed: com.twitter.crashlytics.ios.exception
0 Sprinkles 0x10013a0c0 CLSProcessRecordAllThreads + 4296466624
1 Sprinkles 0x10013a0c0 CLSProcessRecordAllThreads + 4296466624
2 Sprinkles 0x10013a4e0 CLSProcessRecordAllThreads + 4296467680
3 Sprinkles 0x10012b42c CLSHandler + 4296406060
4 Sprinkles 0x100138a00 __CLSExceptionRecord_block_invoke + 4296460800
5 libdispatch.dylib 0x197d516a8 _dispatch_client_callout + 16
6 libdispatch.dylib 0x197d5c954 _dispatch_barrier_sync_f_invoke + 100
7 Sprinkles 0x1001384ac CLSExceptionRecord + 4296459436
8 Sprinkles 0x1001382e8 CLSExceptionRecordNSException + 4296458984
9 Sprinkles 0x100137f48 CLSTerminateHandler() + 4296458056
10 libc++abi.dylib 0x196bd6f44 std::__terminate(void (*)()) + 16
11 libc++abi.dylib 0x196bd685c __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 134
12 libobjc.A.dylib 0x197534094 _objc_exception_destructor(void*) + 330
13 Sprinkles 0x1000e0f4c -[RCTBatchedBridge _handleRequestNumber:moduleID:methodID:params:] + 4296101708
14 Sprinkles 0x1000e0930 __33-[RCTBatchedBridge handleBuffer:]_block_invoke + 4296100144
15 libdispatch.dylib 0x197d516e8 _dispatch_call_block_and_release + 24
16 libdispatch.dylib 0x197d516a8 _dispatch_client_callout + 16
17 libdispatch.dylib 0x197d5d6ec _dispatch_queue_drain + 864
18 libdispatch.dylib 0x197d551ac _dispatch_queue_invoke + 464
19 libdispatch.dylib 0x197d5f5bc _dispatch_root_queue_drain + 728
20 libdispatch.dylib 0x197d5f2dc _dispatch_worker_thread3 + 112
21 libsystem_pthread.dylib 0x197f65470 _pthread_wqthread + 1092
22 libsystem_pthread.dylib 0x197f65020 start_wqthread + 4

Fabric also emails you each day with some basic stats with analytics and number of crashes if any. Unfortunately, my app doesn’t really have that many users, but I imagine if I had 100s of beta users, I would be able to see how many use the app daily and if there were any problems/errors.

Now Fabric isn’t the only solution, doing some searching, I stumbled upon the following StackOverflow article:

How to set up analytics on React Native for iOS

The interesting answer included a link to a react-native-mixpanel project on GitHub. For my next project, I might have to give this a try as I’ve used Mixpanel for web projects and really liked it.

And another interesting project worth looking at is the react-native-fabric project on GitHub. I haven’t given it a try yet, but I might start using it to track specific user events. I have been meaning to actually try building something like this since Fabric provides the the calls to make from XCode but a bridge needed to be created so you could call it from the JS. I still might try implementing this myself since I haven’t tried using RCTBridgeModule yet.

So you want to be a product manager at a startup?

I hear a lot of people ask what makes a good product manager and I also hear a lot of people talk about how they want to be a product manager. The answer to the question and the response I give is the same…

It depends

There is no list of qualifications that ensures that Person A will be a good product manager for Company X. I have seen people with impressive resumes that have led successful product organizations at Company Z and Company Y and when they get to Company X, everything falls apart. It could be that they’ve become too accustomed to success and have lost the hustle. It could be that they didn’t understand the market or the users. It could be that the founders of Company X didn’t have a product that the market wanted. It could be that the founders didn’t let the product manager actually do their job. It could be that they assumed Company X should be run like Company Z and Company Y. And then there’s the possibility that Company X didn’t need a product manager. I’m a firm believer that Company X’s first/best product manager has to be someone who doesn’t have the title of product manager. In addition, they shouldn’t want to be a product manager – the company’s first product manager should be the user. Instead of paying someone to tell you what to do, ask the people who are paying you what you should do. And then do it, do it well and if that gets you more customers, keep asking the same person what to do next. If it doesn’t get you more customers, then go ask someone else. And if you don’t have customers, you new task is to stop looking for a product manager and go find some customers.

Okay, you’ve ignored what I’ve said and you want a product manager and therefore you want to risk hiring someone who looks good on paper and can talk about their successes. But unless you’re hiring someone from a direct competitor, they probably don’t know your market, your users, your product, etc. – with all those challenges, they’ll need the following:

Ruthless prioritization. Saying no to a hundred obviously good things to build the one or two most important things at any given time. Creating a culture of focus, execution, and agility.

Shepard. The product needs a Shepard as it passes from conception to design to engineering to consumers. Unable to prioritize a needed feature? Defend with data and supporting evidence. Development stalled? Find out what’s blocking.

Strong instincts. A good product manager will strive to get the product out the door as quickly as possible, but knows when something just isn’t ready for prime time and will be the one to say so. Good product managers are keepers of a great user experience.

And there’s a bunch of other stuff to look for (strong communication skills, good with engineers/designers, metrics-oriented, detail-oriented, etc.), but if you somehow can verify the above, I’m sure they can figure out the rest. And ultimately, good product managers figure out the rest.

What makes a good engineering culture?

A difficult question with no single answer. I do like a number of the traits listed in the following Quora question:

  1. Optimize for iteration speed
  2. Push relentlessly toward automation
  3. Develop a focus on high code quality with code reviews
  4. Build a culture of learning and continuous improvement

I really like the following description of what it means to be a team and what the objective of a software engineering team should be:

High quality software engineering is the product of a team. No one individual can be expected to deliver, nor take credit for, a successful product on his or her own. This gets fuzzy in small startups where there may only be one engineer, but otherwise holds true. A culture that celebrates one individual at the cost of another is making a grievous mistake.

There is an important distinction to note here about what comprises a *team* of engineers versus a group. The distinction is that a group is not a team until everyone in the group is committed the purpose [1]. In my experience, this commitment comes from inspirational leadership and transparency. The fact that an engineer is employed by a company is not reason enough to incite the determination, dedication, and thoughtfulness necessary to produce quality code. Committed engineers are engineers who are proud to work where they work and excited to talk about their jobs and their company’s products.

Ultimately, a good engineering culture is the result of a complex equation that includes the culture of the company, the objectives of the founders, the product being built and ultimately the first couple engineers. If you want to balance the equation, make sure you have product-engineering fit as well as product-market fit.

 

Warning: possible EventEmitter memory leak detected. 11 change listeners added.

Got an interesting node.js warning on the server while rendering React components. After a little research and this helpful Stack Overflow Question that described the problem being due to adding event listeners in the componentWillMount rather than the componentDidMount. I didn’t realize the distinction that componentWillMount will run while rendering on the server. In any case, this is pretty useful and interesting information that helps me understand how to use componentWillMount and componentDidMount when building components that get rendered on the server. I hope this helps someone out there.

Getting noscript when trying to do server-side/universal rendering

Now this was a pretty frustrating problem that cost me at least 3 days of debugging, investigation and trial/error testing. But basically, this was due to none of the routes matching on the server. Funny thing is that the route did match when running in the browser and it rendered just fine. And just for the record, I’m using Babel 6, React-Router, Redux, and Redux-Simple-Router which is probably why you’re reading this. So I spent a lot of time debugging this code which I got from the examples:

import { renderToString } from 'react-dom/server'
import { match, RouterContext } from 'react-router'
import routes from './routes'

serve((req, res) => {
  // Note that req.url here should be the full URL path from
  // the original request, including the query string.
  match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {
    if (error) {
      res.status(500).send(error.message)
    } else if (redirectLocation) {
      res.redirect(302, redirectLocation.pathname + redirectLocation.search)
    } else if (renderProps) {
      // You can also check renderProps.components or renderProps.routes for
      // your "not found" component or route respectively, and send a 404 as
      // below, if you're using a catch-all route.
      res.status(200).send(renderToString(<RouterContext {...renderProps} />))
    } else {
      res.status(404).send('Not found')
    }
  })
})

Stepping through the code above, renderProps was always undefined. Running other samples, I saw that renderProps should contain the route that will be rendered. So for whatever reason, the URL wasn’t wasn’t matching any of the routes specified. So the reason the routes weren’t matching on the server is because my routes were being included like this:

var routes = "./routes"

And here is how I defined the routes:

module.exports = () => {
 var routes = (
   <Route path={ baseUri } component={ Container }>
     <IndexRoute component={ Home } />
     <Route path='*' component={ NotFound } />
   </Route>
 )
 return routes
}

And again, this setup works perfectly fine when running in the browser. After some trial and error, I decided to try copying the syntax from the example and changed my routes definition to:

export default (
 <Route path="/" component={ Container }>
 <IndexRoute component={ Home } />
 <Route path="*" component={ NotFound } />
 </Route>
)

And guess what, it worked. I’m not sure if  I know why it worked, but for whatever reason, this was the missing piece of the puzzle that got server-side rendering to work. My renderProps was no longer undefined and everything was rendering correctly.

And that’s all folks, hope this helps someone.

Save 50% or $600.99 on LG Electronics 40UB8000 40-Inch 4K Ultra HD 60Hz Smart LED TV

Wow, I did not know 4K display were this cheap… as in $600 for a 40 inch TV cheap… I haven’t decided if I want a TV for my new place, it’s been oddly liberating not coming home and just sitting in front of a TV. I find myself being more productive, going back out and walking around much more. I will binge on Netflix on the iPad or on my mac occasionally, but I’m definitely not spending as much time in front of a TV as I used to. Anyways, this looks like a great deal for a 4K display and I can say that I’ve been a big fan of the LG TVs lately. And here’s one of the better reviews giving the TV 5 out of 5 stars:

Absolutely amazing picture! I haven't had a chance to try gaming in 4k on it because I haven't finished my new build yet but even the 1080p on this thing looks better than your usual 1080p television. I am in love! I can't quit playing all my favorite games on it just being completely amazed by the beautiful details that I never got to see on my old 720p Samsung television. I couldn't be happier!

Thanks to SetSocial.

React Native: cmd+R not working

So I was super excited to start using React Native, it’s been a while since I tried building an iOS app and because I haven’t used Objective-C in a while, I really haven’t had any motivation to build any of the ideas I have had. Then enter React Native and the dream that all the speed and ease of building React apps on the web would be ported to building mobile iOS apps. So as soon as I had free time (which is rare) I started going through the Getting Started guide. Even the Getting Started guide was fast and easy. Got everything downloaded and everything seemed to be working, I was able to create a new project and open it up in Xcode and it built perfectly. But then I made some text changes – my personal favorite is always to add “Hello World” to any app – and then I tried the reload feature by clicking cmd+R in the simulator… wait… nothing… try again… still nothing. That’s weird, everything up until now has been easy and just worked. So I closed the simulator, and tried to rebuild… still not showing my changes… okay, maybe something isn’t being build, I’ll just close down Xcode… bring back Xcode… rebuild.. still nothing… okay, maybe there was something weird with my project, let me blow it away and recreate it… okay, now rebuild… still nothing… getting a little frustrated… let’s just say I decided to walk away and came back a while later… and looking through the GitHub issues for React Native, I found the following:

Cmd-R not refreshing?

Everything loads up fine, example are are running smoothly, but if I make a change in the JS file and hit Cmd-R in the simulator, nothing happens. Did I forget something?

And after going through the thread and trying a few things suggested, I noticed a terminal window that was running in the background:

I also notice that there was a problem with the packager and it wasn’t could initialize. So I kill the process and try again… still nothing… so I decide to try the good old Windows solution and reboot my machine… wait for it… it worked (thanks Microsoft for conditioning me to always do this). So it seems Watchman was in a weird state and wouldn’t actually run, so I had to reboot the machine to get it un-weird. There was probably a way to do it without rebooting my machine, but rebooting was quick and worked. Anyways, I hope this helps someone out there – good luck and happy hacking with React Native.