• Complain

Adam Boduch [Adam Boduch] - React and React Native - Second Edition

Here you can read online Adam Boduch [Adam Boduch] - React and React Native - Second Edition full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: Packt Publishing, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Adam Boduch [Adam Boduch] React and React Native - Second Edition
  • Book:
    React and React Native - Second Edition
  • Author:
  • Publisher:
    Packt Publishing
  • Genre:
  • Year:
    2018
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

React and React Native - Second Edition: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "React and React Native - Second Edition" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Build applications for web and native mobile platforms with React, JSX, Redux, and GraphQL

Key Features
  • Explore how functional web development works with React, Redux, and React Native
  • Build apps with unified architecture with Facebooks React, Relay, and GraphQL
  • Understand the platform in-depth, from routing to server-side rendering
Book Description

This books takes you through using React 16 and React Native 0.5 to create powerful and engaging desktop mobile and native applications for all platforms.

You start by learning how to craft composable UIs using React, ranging from rendering with JSX and creating reusable components to routing and creating isomorphic applications that run on Node.js.

We then move on to show you how to take the concepts of React and apply them to building Native UIs using React Native. Youll find out how to build responsive and streamlined UIs that can properly handle user interactions in a mobile environment. Youll also learn how to access device-specific APIs such as the Geolocation API, and how to handle offline development with React Native.

You will master handling application state, Unified Information Architecture, and using Flux, Redux, and Relay.

Towards the end of the book, you will learn how Flux ideas are encapsulated within React components using Relay and apply all the skills learned so far to create a React application that runs on every major platform.

What you will learn
  • Learn what has changed in React 16 and how you stand to benefit
  • Craft reusable components using the React virtual DOM
  • Learn how to use the new create-react-native-app command line tool
  • Augment React components with GraphQL for data using Relay
  • Handle state for architectural patterns using Flux
  • Build an application for web UIs using Relay
Who this book is for

This book is written for any JavaScript developerbeginner or expertwho wants to start learning how to put both of Facebooks UI libraries to work. No knowledge of React is needed, though a working knowledge of ES2017 will help you follow along better.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Adam Boduch [Adam Boduch]: author's other books


Who wrote React and React Native - Second Edition? Find out the surname, the name of the author of the book and a list of all author's works by series.

React and React Native - Second Edition — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "React and React Native - Second Edition" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Passing property values

Properties are like state data that gets passed into components. However, properties are different from state in that they're only set once, when the component is rendered. In this section, you'll learn about default property values. Then, we'll look at setting property values. After this section, you should be able to grasp the differences between component state and properties.

Forms

In this final section of the chapter, you'll implement some form components from react-bootstrap. Just like the filter buttons you created in the preceding section, form components have state that needs to be passed down from a container component.

However, even simple form controls have many moving parts. First, you'll learn about text inputs. There's the input itself, but there's also the label, the placeholder, the error text, the validation function, and so on. To help glue all these pieces together, let's create a generic component that encapsulates all of the Bootstrap parts:

import React from 'react';
import PropTypes from 'prop-types';
import {
FormGroup,
FormControl,
ControlLabel,
HelpBlock
} from 'react-bootstrap';
// A generic input element that encapsulates several
// of the react-bootstrap components that are necessary
// for event simple scenarios.
const Input = ({
type,
label,
value,
placeholder,
onChange,
validationState,
validationText
}) => (
{label}
type={type}
value={value}
placeholder={placeholder}
onChange={onChange}
/>
{validationText}
);
Input.propTypes = {
type: PropTypes.string.isRequired,
label: PropTypes.string,
value: PropTypes.any,
placeholder: PropTypes.string,
onChange: PropTypes.func,
validationState: PropTypes.oneOf([
undefined,
'success',
'warning',
'error'
]),
validationText: PropTypes.string
};
export default Input;

There are two key advantages to this approach. One is that, instead of having to use , , , and so on, you just need your element. Another advantage is that only the type property is required, meaning that can be used for simple and complex controls.

Let's see this component in action now:

import React from 'react';
import PropTypes from 'prop-types';
import { Panel } from 'react-bootstrap';
import Input from './Input';
const InputsForm = props => (
Inputs
}>
{/* Uses the element to render
a simple name field. There's a lot of
properties passed here, many of them
come from the container component. */}
type="text"
label="Name"
placeholder="First and last..."
value={props.nameValue}
onChange={props.nameChange}
validationState={props.nameValidationState}
validationText={props.nameValidationText}
/>
{/* Uses the "" element to render a
password input. */}
type="password"
label="Password"
value={props.passwordValue}
onChange={props.passwordChange}
/>
);
InputsForm.propTypes = {
nameValue: PropTypes.any,
nameChange: PropTypes.func,
nameValidationState: PropTypes.oneOf([
undefined,
'success',
'warning',
'error'
]),
nameValidationText: PropTypes.string,
passwordValue: PropTypes.any,
passwordChange: PropTypes.func
};
export default InputsForm;

There's only one component used to create all of the necessary Bootstrap pieces underneath. Everything is passed in through a property. Here's what this form looks like:

Now lets look at the container component that controls the state of these - photo 1

Now let's look at the container component that controls the state of these inputs:

import React, { Component } from 'react';
import { fromJS } from 'immutable';
import InputsForm from './InputsForm';
// Validates the given "name". It should have a space,
// and it should have more than 3 characters. There are
// many scenarios not accounted for here, but are easy
// to add.
function validateName(name) {
if (name.search(/ /) === -1) {
return 'First and last name, separated with a space';
} else if (name.length < 4) {
return 'Less than 4 characters? Srsly?';
}
return null;
}
class InputsFormContainer extends Component {
state = {
data: fromJS({
// "Name" value and change handler.
nameValue: '',
// When the name changes, we use "validateName()"
// to set "nameValidationState" and
// "nameValidationText".
nameChange: e => {
this.data = this.data.merge({
nameValue: e.target.value,
nameValidationState:
validateName(e.target.value) === null
? 'success'
: 'error',
nameValidationText: validateName(e.target.value)
});
},
// "Password" value and change handler.
passwordValue: '',
passwordChange: e => {
this.data = this.data.set('passwordValue', e.target.value);
}
})
};
// Getter for "Immutable.js" state data...
get data() {
return this.state.data;
}
// Setter for "Immutable.js" state data...
set data(data) {
this.setState({ data });
}
render() {
return ;
}
}
export default InputsFormContainer;

The event handlers for the inputs are part of the state that get passed to InputsForm as properties. Now let's take a look at some checkboxes and radio buttons. You'll use the and the react-bootstrap components:

import React from 'react';
import PropTypes from 'prop-types';
import { Panel, Radio, Checkbox, FormGroup } from 'react-bootstrap';
const RadioForm = props => (
Radios & Checkboxes
}>
{/* Renders a group of related radio buttons. Note
that each radio needs to hae the same "name"
property, otherwise, the user will be able to
select multiple radios in the same group. The
"checked", "disabled", and "onChange" properties
all come from the container component. */}
name="radio"
onChange={props.checkboxEnabledChange}
checked={props.checkboxEnabled}
disabled={!props.radiosEnabled}
>
Checkbox enabled
name="radio"
onChange={props.checkboxDisabledChange}
checked={!props.checkboxEnabled}
disabled={!props.radiosEnabled}
>
Checkbox disabled
{/* Reanders a checkbox and uses the same approach
as the radios above: setting it's properties from
state that's passed in from the container. */}
onChange={props.checkboxChange}
checked={props.radiosEnabled}
disabled={!props.checkboxEnabled}
>
Radios enabled
);
RadioForm.propTypes = {
checkboxEnabled: PropTypes.bool.isRequired,
radiosEnabled: PropTypes.bool.isRequired,
checkboxEnabledChange: PropTypes.func.isRequired,
checkboxDisabledChange: PropTypes.func.isRequired,
checkboxChange: PropTypes.func.isRequired
};
export default RadioForm;

The radio buttons toggle the enabled state of the checkbox and the checkbox toggles the enabled state of the radios. Note that, although the two elements are in the same , they need to have the same name property value. Otherwise, you'll be able to select both radios at the same time. Here's what this form looks like:

Finally lets look at the container component that handles the state of the - photo 2

Finally, let's look at the container component that handles the state of the radios and the checkbox:

import React, { Component } from 'react';
import { fromJS } from 'immutable';
import RadioForm from './RadioForm';
class RadioFormContainer extends Component {
// Controls the enabled state of a group of
// radio buttons and a checkbox. The radios
// toggle the state of the checkbox while the
// checkbox toggles the state of the radios.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «React and React Native - Second Edition»

Look at similar books to React and React Native - Second Edition. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «React and React Native - Second Edition»

Discussion, reviews of the book React and React Native - Second Edition and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.