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: ‘api.blog.com/posts’, 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”

front end developer [react and rails a +]

  • Are you an Engineer looking to revolutionize the way people innovate and build software?
  • Do you want to create something that will change the way people think about innovation, and work with cutting-edge visualization, collaboration, and social ideation technologies at the same time?
  • was founded by a proven team of Silicon Valley veterans whose last two businesses were acquired by well-known public companies.
  • to link their brilliant strategy to their team’s work and create visual roadmaps.
  • If you have the right background, we will quickly follow up with you.

As a Front End Developer at Aha!, you will have an excellent opportunity to join a breakthrough and profitable company that is growing fast.
Continue reading “front end developer [react and rails a +]”

180 Websites in 180 Days: Day 38 – Aaron Massey – Medium

  • 180 Websites in 180 Days: Day 38Check out today’s and the rest of this projects challenges here!Don’t know how I forgot to do this blog post yesterday!Woke up to a new video from one of the YouTube channels I subscribe to, CodingTutorials360, about a Free Code Camp project I was planning on doing soon.
  • I decided to just go ahead and do it because I wanted to see how he sorted his lists.The way I previously sorted my lists was just to have each version of the lists already rendered and a different list would be shown depending on the sort method.
  • I thought there would be a way to actually sort through one list without the need of rendering others.
  • However, I did learn some simpler methods of doing some things which is always a plus!If any of you have done the Free Code Camp Front End Projects and are looking for more to do be sure to check the FCC beta.

Woke up to a new video from one of the YouTube channels I subscribe to, CodingTutorials360, about a Free Code Camp project I was planning on doing soon. I decided to just go ahead and do it because I…
Continue reading “180 Websites in 180 Days: Day 38 – Aaron Massey – Medium”

Why Do Developers Now Compare Vue.js to JavaScript Giants Angular and React?

  • It was 2016 when Vue.js rose to fame and gained so much traction that it’s now seen as an alternative for even well established JavaScript libraries, such as Angular and React.
  • Since Angular belongs to search engine giant Google and React comes from social media behemoth Facebook, developers still trust and use those libraries more than Vue.js.
  • This blog attempts to shed light on why there is a growing belief among developers that Vue.js is set to become the top JavaScript library, leaving behind Angular and React.
  • The reason many developers are turning to Vue is that it addresses the issues of React and Angular.
  • But, one must not forget that Angular and React are still very big names in the JavaScript world, whereas Vue has just begun to rise.

Vue.js, an MIT-licensed open source project, is a JavaScript library for building web interfaces. The library was first released in 2013, but not many developers took cognizance of it in web framework technology for the next two years. It was 2016 wh
Continue reading “Why Do Developers Now Compare Vue.js to JavaScript Giants Angular and React?”

Mocking API responses with React Apollo – Carlos Martinez – Medium

  • Mocking API responses with React ApolloApollo Client and the GraphQL tools that have been made open source within the last years are pretty awesome, the community that is being builded around them is great.
  • However, as with every new technology, there are a lot of things that need to mature and improve.Documentation on testing is definitely one of the bits that needs a lot of improvements, it isn’t clear what to do, and I personally found myself digging into the source code to understand what to do.One of the problems I faced was that I wanted to use mock responses when testing my app components, and there are at least two ways of doing this:The first way is to use graphql-tools.
  • From their docs:This package allows you to use the GraphQL schema language to build your GraphQL.js schema, and also includes useful schema tools like per-type mocking.You can use this library together with a custom MockNetworkInterface to return mocked responses to your components:const { mockServer } = require(“graphql-tools”);const { print } = MockNetworkInterface { constructor(schema, mocks = {}) { if (!
  • schema) { throw new Error(‘Cannot create Mock Api without specifying a schema’); } this.mockServer = mockServer(schema, mocks); } query(request) { return request.variables); }}This is nice, and very flexible, with graphql-tools you can do pretty much whatever you do in your actual API.What I didn’t like about this approach is that you need your schema in sync with the schema defined in your API (you can do this making an instrospection query to your backend), I also found this approach overcomplicates things unnecessarily.The second (and simpler) approach I found was to use the mockNetworkInterface class, this class is defined in react-apollo/test-utils, you can have a peek on it here.To use it, you first need to define some Mock Requests (these requests need to be exactly the same your components will make):const GraphQLMocks = [ { request: { query: UserProfileQuery, variables: {} }, result: { data: { current_user: { id: 1, first_name: ‘Foo’, last_name: ‘Bar’, email: ‘foo@example.com’ } } } }];The UserProfileQuery is exported from your component:export const UserProfileQuery = gql` query userProfile { current_user { id first_name last_name email } }`;And this is how you use it to setup your tests:import { mockNetworkInterface } from ApolloClient from ‘apollo-client’;import { ApolloProvider } from ‘react-apollo’;import { mount } from ‘enzyme’;import App from ‘.
  • /App.js’;import React from ‘react’;const setupTests = () = { const networkInterface = // or mocks); const client = new ApolloClient({ networkInterface, addTypename: false }); const wrapper = mount( ApolloProvider client={client} App / /ApolloProvider ); return { wrapper };};It is important that you pass addTypename: false to ApolloClient, otherwise you would have to include a __typename field in all your mocks and queries.Now any queries your components make will be handled by your mocked responses, you have full control of what you want to return.And that’s it!

Apollo Client and the GraphQL tools that have been made open source within the last years are pretty awesome, the community that is being builded around them is great. However, as with every new…
Continue reading “Mocking API responses with React Apollo – Carlos Martinez – Medium”

React.js Structures JavaScript for Easy Componentization  

  • JavaScript is in the midst of transforming development teams’ expectations for desktop, server and mobile apps.
  • Enhancements to JavaScript are enabling it to break free of the browser, while technologies such as Node.js and its package manager npm facilitate creation of portable front-end and back-end apps that rival those traditionally created for environments such as Windows, Linux and mobile devices.
  • Components encapsulate the necessary HTML, JavaScript and CSS for a particular component, and apps are built by composing components into larger components that encapsulate their own data and logic.
  • React and Facebook provide a number of recommendations and best practices to help developers build their apps, but developers ultimately shoulder the burden of building the app — creating or procuring the various components, designing the data architecture and testing plan, establishing the look and feel of the app, adapting to necessary display environments, and so forth.
  • Many of the ExtReact components leverage the data package to provide consistent buffering, sorting, filtering and pagination capabilities with minimal developer effort.

JavaScript is in the midst of transforming development teams’ expectations for desktop, server and mobile apps. Enhancements to JavaScript are enabling it to break free of the browser, while technologies such as Node.js and its package manager npm facilitate creation of portable front-end and back-end apps that rival those traditionally created for environments such as Windows, Linux and mobile devices.
Continue reading “React.js Structures JavaScript for Easy Componentization  “