Best practices for JavaScript function parameters

  • The problem with passing an object as a parameter to a function is that it’s not clear what values you should put into it.
  • One common thing in FP is to partially apply your functions, which is much harder to do if your function takes its parameters as an object.
  • While separate parameters are a good starting point, we run into trouble as soon as the function has optional parameters.
  • For functions with a single optional parameter, the solution is simple:

    Best practice: optionals come last

    However, if we have more than one optional parameter, the problem is… what if we only need to pass one optional parameter?

  • You can pass in parameters easily as an object, but the properties for the object can be easily seen from the function’s signature.

From time to time, people ask things like “should I use objects to pass function arguments”. I’m sure you recognize the pattern, as it’s common with many libraries:
Continue reading “Best practices for JavaScript function parameters”

Just published a small library to make performant masonry layout lists with ReactNative

  • Allows creating masonry style list layouts in a performant way.
  • This component leverages to render performant masonry layout lists.
  • This component supports most of the props of plus a few extras one:

    Returns the height for a specific item.

Contribute to react-native-masonry-list development by creating an account on GitHub.
Continue reading “Just published a small library to make performant masonry layout lists with ReactNative”

8 Reasons Why React.JS is the Best Technology to Develop Kickass Web and Mobile Apps

8 reasons why #reactjs is the best technology to develop kickass web and mobile apps.

  • Any JavaScript developer would find it easy to comprehend the basics of React JS and start developing web apps using this technology within a few days of mastering the docs and tutorials.
  • One of the main reasons to opt for React JS for the web and mobile app development is the JavaScript library.
  • That is why React JS is steadily gaining popularity among the developers of the web and mobile apps.
  • If you are a developer who is concerned with single page applications and want to come up with fast, user-friendly, and responsive apps, React JS is definitely a worthy choice.
  • Considering the advantages offered by this technology, there is no reason why React JS won’t be welcomed by developers in pursuit of creating advanced web and mobile apps.

So what makes React JS a preferred technology to develop kickass web and mobile apps? We list down 8 top reasons in support of it. 1. Easy to learn and master. 2. Simple to write components
Continue reading “8 Reasons Why React.JS is the Best Technology to Develop Kickass Web and Mobile Apps”

GitHub

A React Native 'Ratings' Component with Gesture Support:

  • An extendable Rating’s components for React Native with gestures and an intuitive API

    Install the package using yarn or npm:

    You can try it out with Exponent here.

  • One of my friends showed me this Star Rating feature in Bootstrap and it looks really interesting.
  • So I challenged myself to re-implement it in React Native.

react-native-ratings – React Native Ratings component with super customizations and much gestures.
Continue reading “GitHub”

react-native-web/style.md at master · necolas/react-native-web · GitHub

  • React Native for Web implements the React Native style API in a way that avoids all the problems with CSS at scale:

    At the same time, it has several benefits:

    Styles should be defined outside of the component.

  • React Native style resolution is deterministic and slightly different from CSS.
  • React Native for Web transforms React Native styles into React DOM styles.
  • Any dynamic styles that contain declarations previously registered as static styles can also be converted to CSS class names.
  • React Native for Web includes a very small CSS reset that removes unwanted User Agent styles from (pseudo-)elements beyond the reach of React (e.g., , ) or inline styles (e.g., ).

react-native-web – React Native for Web
Continue reading “react-native-web/style.md at master · necolas/react-native-web · GitHub”

How to Organize a Large React Application and Make It Scale — SitePoint

  • In this article, I’ll talk you through the decisions I make when building React applications: picking tools, structuring files, and breaking components up into smaller pieces.
  • /lib/baz’

    When you’re building your app with Webpack you can tell Webpack to always look in a specific directory for a file if it can’t find it, which lets you define a base folder that all your imports can become relative to.

  • For example, my top level folder structure often contains:
    – src = app code here
    – webpack = webpack configs
    – scripts = any build scripts
    – tests = any test specific code (API mocks, etc)

    Typically the only files that will be at the top level are index.html, package.json, and any dotfiles, such as .

  • Normally our React files look like so:
    import React, { Component, PropTypes } from ‘react’

    export default class Total extends Component {

    }

    In the case that we have to wrap the component in order to connect it to a Redux data store, for example, the fully wrapped component becomes the default export:
    import React, { Component, PropTypes } from ‘react’
    import { connect } from ‘react-redux’

    export class Total extends Component {

    }

    export default connect(() = {…})(Total)

    You’ll notice that we still export the original component; this is really useful for testing where you can work with the “plain” component and not have to set up Redux in your unit tests.

  • Although we don’t recognize it by splitting them into folders, you can broadly split our app into two types of components:
    “smart” components that manipulate data, connect to Redux, and deal with user interaction
    “dumb” components that are given a set of props and render some data to the screen
    You can read more about how we aim for “dumb” components in my blog post on Functional Stateless Components in React.

Jack Franklin describes a set of tips and best practices for creating and organizing React applications in a scalable way.
Continue reading “How to Organize a Large React Application and Make It Scale — SitePoint”

A gentle Introduction to Higher Order Components

A gentle Introduction to Higher Order Components:  by @rwieruch #JavaScript #ReactJS

  • I want to pick out one use case, the conditional rendering with higher order components, to give you two outcomes from this article as a reader.
  • First, it should teach you about higher order components with the use case of conditional rendering.
  • Keep in mind, that altering the look of a component with a higher order component, specifically in the context of conditional rendering, is only one of several use cases to use HOCs.
  • In order to teach higher order components, the article focuses on the use case of conditional rendering.
  • Now you could use the higher order component but with a function that determines the conditional rendering.

Higher order components, or known under the abbreviation HOCs, are often a hard to grasp pattern in React. The article gives you an introduction to HOCs, how to use them elegantly in the case of conditional rendering and how to abstract them…
Continue reading “A gentle Introduction to Higher Order Components”