background preloader

React

Facebook Twitter

A journey into Reactive User Interfaces 101. A journey into Reactive User Interfaces 101 Okay.

A journey into Reactive User Interfaces 101

Before we start, let’s identify who this post is for by sending out a quick spec: By the product spec, whenever a user has a role of “Administrator” their profile picture must be outlined in a blue color. If the user has a different role, remove that outline and add this blue color. If the user doesn’t have a role, return their outline to the normal gray color. Now as programmers, when we hear product specs like this we immediately start thinking of the WHO, WHAT, and HOW surrounding this. If your first inclination was to use jQuery to find the user profile on the DOM, check if it had a class, remove said class and add a new class…this post is for you.

Now, don’t get me wrong. What is a Reactive User Interface? Reactive User Interfaces are a declarative way of expressing your app’s visual representation of DATA. Okay, let’s implement the spec. A production-ready realtime SaaS with webpack. A production-ready realtime SaaS with webpack I’m a huge fan of Meteor.

A production-ready realtime SaaS with webpack

It socketizes everything, transpiles your styles, and gives you a big chunk of code to push to a server. Sometimes though, you need something more flexible. Like any standard Saas, I needed a small landing page I could serve from a CDN, a portal that offered a realtime websocket experience, and an easy path to scale both vertically and horizontally. The end result is something I call Meatier, which I open sourced on github: The package solves a lot of problems (JWT authentication & authorization, scaling sockets, using redux as a client-side cache, storing socket state in redux, optimistic & realtime database updates, etc.) but for this entry, I decided to focus on webpack. A Reusable State Container with Meteor & React. A Reusable State Container with Meteor & React Today I’m going to show off a little component you can make to serve as a nice state container.

A Reusable State Container with Meteor & React

We’ll mix the reactivity of Meteor and the components of React to build a predictable user interface. What are container components? A container does data fetching and then renders its corresponding sub-component. That’s it. The Goal. Building a Blog with React. What we're going to learn In this recipe, we'll work with HD Buff, a curated video streaming service to create a blog for their website using React.

Building a Blog with React

We'll see how to create a simple admin area, retrieve posts, and even handle things like Markdown directly from our React components! Pre-Written Code Heads up: this recipe relies on some code that has been pre-written for you, available in the recipe’s repository on GitHub. Building Multi-Platform Native Apps with Meteor - Tom Goldenberg. Building Your Second React.js App — Learning New Stuff. Building Your Second React.js App Getting into more advanced features This is the second post in a series of tutorials on React.js.

Building Your Second React.js App — Learning New Stuff

The first one took you through building a very simple profile page with the popular Javascript library: This time we’ll introduce some more basic concepts: StateEvent handlersComponent life cyclesReact & API’s Looking at the project You’ll build an app which searches the iTunes API based on user inputs and displays the results on the page. If we break the UI into components it’ll look something like this: The red component App is the main wrapper for all the other components. The Results component also has its own children called ResultItem (yellow). We can also visualize the component structure like this: --App-----SearchBox-----Results-------ResultItem Step 1: Download the template You’ll find the template for the app at this GitHub repo, in the index.html file.

Click to Edit Fields in React. What we're going to learn In this snippet, we'll learn how to implement a click-to-edit interface for items in a list using React.

Click to Edit Fields in React

We'll see how to handle conditional rendering of input fields for editing, as well as how to make changes when a single field changes as well as when all fields change. When our application deals with long lists of data, managing the process of editing that data can be a pain, both for us and our users. In some cases, the data in our lists is tabular, meaning our data more or less mimics tables or fields in our database. Dynamic Fields Using Data in React. What we're going to learn In this snippet, we're going to learn how to leverage reactive data in Meteor to generate DOM elements in Meteor.

Dynamic Fields Using Data in React

We'll learn about wiring up a set of React components to our database, allowing us to easily generate new DOM elements by storing placeholder data. Forms are tricky. When we have a form with a static set of fields, all we really need to do is write our markup (or use a package) and be done with it. But what about dynamic form fields? There are several solutions to this problem. Dynamic Fields Using Data in React. Getting Started with Meteor, React, and React Router. React.js and Meteor.js are great technologies for creating apps for the modern web.

Getting Started with Meteor, React, and React Router

A recently announced feature with Meteor 1.2 is official React support. This means developers can now use React for handling client views without even needing to use Blaze or template files. I have spent a lot of time in the past few weeks learning React and using it in Meteor. Adding additional libraries for React can be troublesome if you aren't familar with the Meteor stack. How we Redux — Part 1 (Introduction) — Modern User Interfaces. How we Redux — Part 1 (Introduction) For anyone new to React, Flux and other buzzwords, today I wanted to explain how we implement Redux, a certain flavor of Flux architecture, in MeteorJS.

How we Redux — Part 1 (Introduction) — Modern User Interfaces

Over the past few weeks, the Meteor community has seen a surge of developers replacing the previous view layer, Blaze, which was predominantly “reactive” templating to React, JSX, and all the trinkets the React community has provided. If you want some insight into Templating vs. JSX, you can read my blog post introducing the change to JSX here. This blog post will be a series, this post being an introduction to high level concepts of Redux. Enter Redux If you want some more info on Redux, check this blog post by Dan Abramov here. One thing you’ll notice about Redux immediately is the “single state atom”. Interacting with your state this way allows your code to be more straightforward and can introduce some really cool concepts like time-travel debugging and reproducible error-reporting. Meteor + React: Hello World. React for Meteor Developers. What is React?

React for Meteor Developers

React is a JavaScript library built by a group of engineers at Facebook and Instagram. It describes itself as a "JavaScript library for building user interfaces". Whereas other JavaScript libraries like Angular and Ember contain features related to data fetching, data modeling, controllers, etc - React is only concerned with the "view" of your application. Build and publish React Native apps without installing Xcode. Spencer Dixon - Test Driven React Tutorial. Testing is an important part of the development cycle. There is a name for code without tests: legacy code. When I first started learning React and JavaScript it was overwhelming to say the least. If you're new to the JS/React community you're probably feeling super overwhelmed as well. Thinking things like: Which build tool should I use? That's why I decided to write this post. All the code for this tutorial is available on my github located here. Let's get started! Setting Up Webpack.