Maximizing Debuggability with Redux – LogRocket

Making #Redux apps easier to debug #reactjs #webdev via @LogRocketJS

  • By using front end logging tools like LogRocket, developers can easily understand and fix tricky bugs in production by reviewing the actions and state changes leading up to a bug.While this information is immediately useful in any Redux app, there is a lot more we can achieve by architecting an app with logging in mind.
  • When debugging issues, we can dig into this state object to see information on in-flight requests, queryCount (if we’re polling on a query), and timings.Storing this information in Redux is critical, since it puts full context on all network activity in the Redux logs.Rolling your own data fetching “framework”If you’d prefer a simpler approach, you can roll your own data fetching “framework” by simply dispatching explicit actions when querying and receiving data from the network.For example, lets say we’re building a blogging app.
  • This would then update state appropriately to:postsQuery: { url: ‘’, isPending: true, data: […],}This example is far from thorough, but the idea is that by being explicit with Redux actions for each part of the request lifecycle, it becomes easy to debug any potential race condition or network error.Handling other sources of non-determinismIn addition to network fetching, there are lots of other sources of non-determinism that can cause bugs.
  • For example:myWebSocket.onmessage = function (event) { store.dispatch({ type: ‘BLOG_POST_UPDATE_RECEIVED’, payload: event, } }That way, when looking at the Redux logs for an error or user-reported issue, we can see all the data that was received over the websocket and, crucially, relate it in time to other redux actions and network requests.Local StorageOften, an app needs to read from local storage when it first starts up.
  • Once you get the library set up, you’ll see a new key in your Redux store called routing with information on the current router state.In addition, react-router-redux dispatches actions like @@router/LOCATION_CHANGE when its state changes.Also of note is that using react-router-redux lets you rewind router state when time-traveling in redux-devtools, since its state its state is derived from the state in Redux.A note about local vs Redux stateI don’t want to get into the debate on local vs Redux state here, but production Redux logging does change the calculus of this decision in some cases.

In my last blog post, Redux Logging in Production, I discussed one of the most important benefits of using Redux — debuggability. By using front end logging tools like LogRocket, developers can…
Continue reading “Maximizing Debuggability with Redux – LogRocket”

Check my Universal Reactjs boilerplate #es6 #javascript #mongodb #nodejs #reactjs #redux #webdev #webdevelopment

  • , contains dumb React components which depend on containers for data.
  • , contains starting template (if project got cleaned with ).
  • Container care about how things work, while Component care about how things look.
  • You can see the sample app with this script if you’re not cleaning the project yet

    Before start the new project, you can use this script to remove the sample app, this script will remove everything inside and directories, and generate the starting and

    Bundle all the files, it will create the for all the style files, for the client app, and for the server app.

  • If you want to see your project in production environtment

    This Universal ReactJS Starter-kit is packed with plop generator, you can generate component or container template using this script

universal-react-starter – Universal React starter with Redux, React Router, Express, CSS/SASS Module, Mongoose, Webpack.
Continue reading “Check my Universal Reactjs boilerplate #es6 #javascript #mongodb #nodejs #reactjs #redux #webdev #webdevelopment”

Using Electrode to Improve React Server Side Render Performance By Up To 70%

  • js application platform that powers with several goals in mind, including ease of use, re-usability of components across applications and, most importantly, performance.We use server side rendering for almost all of our applications for two reasons:Improved performance for the customerBetter for SEOIn our tests, however, we found that React’s renderToString() takes quite a while to execute — and since renderToString() is synchronous, the server is blocked while it runs.
  • Every server side render executes renderToString() to build the HTML that the application server will be sending to the browser.To solve this problem, we created two Electrode modules: Above the Fold Render (ATF) and Server Side Render Profiling and Caching (SSR Caching).
  • The average renderToString()call with this configuration took 153.80 ms.Electrode default, though, Electrode comes with renderWithIds:false, which gives us a renderToString() time of 124.80 ms. Not bad — Electrode’s default configuration has already improved render time by 19%!
  • That drops our renderToString() time all the way to 36.56 ms — an astounding 71% improvement from the default Electrode configuration, and a 76% improvement from our original, unoptimized test.
  • That means a 70% improvement won’t mean 90 ms, but 180 ms saved.Special Thanks:To Arunesh Joshi, Dmitry Yesin, and the home page team who have implemented the Electrode modules and are using them on the home page in production.To Caoyang Shi, for helping to gather data and ensuring we’re getting the right numbers!More Information:Check out Joel Chen’s post on ReactJS SSR Profiling and Caching or Arpan Nanavati’s post on Building React.js at Enterprise Scale.Check out my post about the release of Electrode, the customer-facing platform that powers Electrode website:

We built Electrode, the react/node.js application platform that powers with several goals in mind, including ease of use, re-usability of components across applications and, most…
Continue reading “Using Electrode to Improve React Server Side Render Performance By Up To 70%”

Even Better Support for React in Flow – Flow – Medium

Even Better Support for React in Flow @calebmer  #Reactjs #Javascript #Webdev

  • It is time to rethink how Flow models React.In Flow 0.53.0 we are changing how Flow models React and in doing this we can provide better types for higher-order components, strict typing for React children, and fixes for a host of bugs in Flow’s React support.The biggest change we are making is to modify how you define React class components.
  • A React component in 0.53.0 looks like this:type Props = { foo: number,};type State = { bar: number,};class MyComponent extends React.ComponentProps, State { state = { bar: 42, }; render() { return +; }}When your component has no state, you only need to pass in a single type argument.
  • Without state your component definition would look like this:type Props = { foo: number,};class MyComponent extends React.ComponentProps { render() { return; }}If your component has default props then add a static defaultProps property:type Props = { foo: number,};class MyComponent extends React.ComponentProps { static defaultProps = { foo: 42, }; render() { return; }}Flow will infer the type of default props from your static property.
  • For the React Router example above, you would type the Route component’s children as:type Props = { children: (data: { match: boolean }) = React.Node, path: string,};class Route extends React.ComponentProps { /* … */ }To learn more about typing React children read our documentation guide on the topic.The children prop returns a React.Node, which is the type for any value that can be rendered by React.
  • Here is how you would type a simple higher-order component that injects a number prop, foo:function injectPropProps: {}( Component: React.ComponentType{ foo: number } Props,): React.ComponentTypeProps { return function WrapperComponent(props: Props) { return Component {…props} foo={42} /; };}class MyComponent extends React.Component{ a: number, b: number, foo: number,} {}const MyEnhancedComponent = injectProp(MyComponent);// We don’t need to pass in `foo` even though// `MyComponent` requires it!MyEnhancedComponent a={1} b={2} /;Here we use the new React.ComponentTypeProps utility along with an intersection to inject the prop foo.Even MoreThere is a lot more that we fit into this release for our React support.

The first version of Flow support for React was a magical implementation of React.createClass(). Since then, React has evolved significantly. It is time to rethink how Flow models React. In Flow 0.53…
Continue reading “Even Better Support for React in Flow – Flow – Medium”

Become a Professional React Developer

Discover the #Javascript library used by the world's most successful companies  #reactjs

  • Learn directly from Udacity’s Head of Recruiting!
  • React is completely transforming Front-End Development.
  • Master this powerful UI library from Facebook with Udacity and the experts from React Training.
  • To succeed in this program, you need to have experience with building front-end web applications with:

    You should have familiarity with the following:

React is completely transforming Front-End Development. Master this powerful UI library from Facebook with Udacity and the experts from React Training.
Continue reading “Become a Professional React Developer”

Announcing “Advanced React.js Online” – componentDidBlog

  • I can barely believe it, but over the last 27 months, Michael Jackson and I have taught React.js to over 3,500 developers at 91 workshops in eight different countries (Oh, and one prison cell in the UK, but I digress…)In that time we’ve learned a lot about React as library authors, product developers, and teachers.We’re the authors of React Router.
  • That kind of usage has exposed us to the needs of all sorts of applications, pushing us to find simpler ways to be composable as library authors.Meeting 3,500 people (and more at the meet ups we regularly attend in our travels) has put a lot of code in front of us, and even more conversations about code.
  • It’s been fun learning the unique needs of all these people and figuring out ways to make their code better as product developers.Teaching React to thousands has helped us identify parts that some folks initially struggle with.
  • This helps us refine our material one workshop at a time, making us much better teachers.We’re happy to announce that we’re bringing all of that experience to you in our very first online course: Advanced React.js.
  • We’ve taken the most popular parts of our workshops and put them into the course.

Ninety-one. I can barely believe it, but over the last 27 months, Michael Jackson and I have taught React.js to over 3,500 developers at 91 workshops in eight different countries (Oh, and one prison…
Continue reading “Announcing “Advanced React.js Online” – componentDidBlog”

All About React Router 4

  • In some ways, earlier versions of React Router resembled our traditional mental model of what an application router “should be” by placing all the routes rules in one place.
  • Here are some JavaScript concepts you need to be familiar with for this article:

    If you’re the type that prefers jumping right to a working demo, here you go:

    Earlier versions of React Router centralized the routing rules into one place, keeping them separate from layout components.

  • For the first, let’s modify our to accommodate the browsing and profile pages for users and products:

    While this does technically work, taking a closer look at the two user pages starts to reveal the problem:

    New API Concept: is given to any component rendered by .

  • Here’s a different approach which is better:

    Instead of four routes corresponding to each of the user’s and product’s pages, we have two routes for each section’s layout instead.

  • For example, both these console logs will output the same value when the browser path is `/users`:

    ES2015 Concept: is being destructured at the parameter level of the component function.

This post is going to dig into to React Router 4, how it’s so different from previous React Router versions, and why that is. My intentions for this article aren’t to rehash the already well-written documentation for React Router 4. I will cover the most common API concepts, but the real focus is on patterns and strategies that I’ve found to be successful.
Continue reading “All About React Router 4”