Sponsored Links

Kamis, 25 Januari 2018

Sponsored Links

React: The Hype is Real - Treehouse Blog
src: blog.teamtreehouse.com

In computing, React (sometimes styled React.js or ReactJS) is a JavaScript library for building user interfaces.

It is maintained by Facebook, Instagram and a community of individual developers and corporations.

React allows developers to create large web-applications that use data and can change over time without reloading the page. It aims primarily to provide speed, simplicity, and scalability. React processes only user interfaces in applications. This corresponds to View in the Model-View-Controller (MVC) pattern, and can be used in combination with other JavaScript libraries or frameworks in MVC, such as AngularJS.


Video React (JavaScript library)



History

React was created by Jordan Walke, a software engineer at Facebook. He was influenced by XHP, an HTML component framework for PHP. It was first deployed on Facebook's newsfeed in 2011 and later on Instagram.com in 2012. It was open-sourced at JSConf US in May 2013.

React Native, which enables native Android, iOS, and UWP development with React, was announced at Facebook's React.js Conf in February 2015 and open-sourced in March 2015.

On April 18, 2017, Facebook announced React Fiber, a new core algorithm of React framework library for building user interfaces. React Fiber will become the foundation of any future improvements and feature development of the React framework.


Maps React (JavaScript library)



Basic usage

The following is a rudimentary example of how React can be used in html using JSX and the ECMAScript 2015 JavaScript syntax.

The Greeter class is a React component that accepts a property greeting. The ReactDOM.render method creates an instance of the Greeter component, sets the greeting property to 'Hello World' and inserts the rendered component as a child element to the DOM element with id myReactApp.

Babel will transpile the above ECMAScript 2015 class code to ES5 code to the following:

When displayed in a web browser the result will be


Vue vs React: Battle of the Javascript Frameworks
src: cdn.deliciousbrains.com


Notable features

One-way data flow

To use React to its greatest potential, Properties (or props), ideally a set of immutable values, are passed to a component's render function. A component should not directly modify any properties passed to it, but should be passed callback functions that instead modifies the store creating a single source of truth. This mechanism's promise is expressed as "properties flow down; actions flow up". The described mechanism is an architecture called Flux. Many Flux alternatives have been created since its inception however the community has moved toward Redux.

Virtual DOM

Another notable feature is the use of a "virtual Document Object Model", or "virtual DOM". React creates an in-memory data structure cache, computes the resulting differences, and then updates the browser's displayed DOM efficiently. This allows the programmer to write code as if the entire page is rendered on each change, while the React libraries only render sub components that actually change.

JSX

React components are typically written in JSX, a JavaScript extension syntax allowing quoting of HTML and using HTML tag syntax to render subcomponents. This is a React-specific grammar extension to JavaScript like the now-defunct E4X. HTML syntax is processed into JavaScript calls of the React framework. Developers may also write in pure JavaScript. JSX is similar to another extension syntax created by Facebook for PHP, XHP. JSX looks like regular HTML. An example of JSX code:

Nested elements

Multiple elements need to be wrapped in a single container element like the <div> element shown above. As of React v16.0 it is now possible to return an array of elements, fragments and strings.

Attributes

Custom attributes are supported in addition to HTML attributes. The custom attributes need to be added with the data- prefix. Custom attributes as of v16.0 are now passed through to the DOM.

JavaScript expressions

JavaScript expressions (but not statements) can be used inside JSX with curly brackets {}:

The example above will render

  <div>    <h1>11</h1>  </div>  
Conditional statements

If-else statements cannot be used inside JSX but conditional expressions can be used instead. The example below will render { i === 1 ? 'true' : 'false' } as the string 'true' because i is equal to 1.

Not only can you return strings via conditional operators you can also pass functions and fragments of code.

The example above if arr has values (of which it has 3) will render:

  <div>    <div>Section 1</div>    <div>Section 2</div>    <div>Section 3</div>  </div>  

Architecture beyond HTML

The basic architecture of React applies beyond rendering HTML in the browser. For example, Facebook has dynamic charts that render to <canvas> tags, and Netflix and PayPal use isomorphic loading to render identical HTML on both the server and client.

React Native

React Native was announced by Facebook in 2015, applying the React architecture to native Android, iOS, and UWP applications.

History

At TechCrunch Disrupt San Francisco 2012, Mark Zuckerberg had the following quote: "Our Biggest Mistake Was Betting Too Much On HTML5" . He promised that Facebook will deliver better mobile experiences very soon.

Inside Facebook, Jordan Walke found a way to generate iOS UI elements from a background Javascript thread. They decided to organize an internal hackathon to perfect this prototype in order to be able to build native apps with this technology..

After few months of development, Facebook released the first version for the React.js Conf 2015. During a technical talk, Christopher Chedeau explained that Facebook was already using React Native in production for their Group App and their Ads Manager App.

Working Principles

The working principles of React Native are basically the same as ReactJS except that it's not manipulating the DOM via the VirtualDom but some native views. It runs in a background process (which interprets the Javascript written by the developers) directly on the end-device and communicates with the native platform via a serializable, asynchronous and batched Bridge.

It can be seen that Facebook corrected the error that Mark Zuckerberg mentioned in 2012: React Native doesn't rely on HTML5 at all, everything is written in Javascript and relies on native SDKs.

Hello World

Hello, World program in React Native looks like that:


15 Interesting JavaScript and CSS Libraries for August 2017 ...
src: tutorialzine.com


Future development

Project status can be tracked via the core team discussion forum. However major changes to React go through the Future of React repo, Issues and PR. This enables the React community to provide feedback on new potential features, experimental APIs and JavaScript syntax improvements.

Sub projects

The status of the React sub-projects used to be available in the project wiki.

Facebook CLA

Facebook requires contributors to React to sign the Facebook CLA.


Advantages of React JS: Open-source JavaScript Library - Anadea
src: anadea.info


Licensing controversy

The initial public release of React in May 2013 used a standard Apache License 2.0. In October 2014, React 0.12.0 replaced this with a 3-clause BSD license and added a separate PATENTS text file that permits usage of any Facebook patents related to the software:

"The license granted hereunder will terminate, automatically and without notice, for anyone that makes any claim (including by filing any lawsuit, assertion or other action) alleging (a) direct, indirect, or contributory infringement or inducement to infringe any patent: (i) by Facebook or any of its subsidiaries or affiliates, whether or not such claim is related to the Software, (ii) by any party if such claim arises in whole or in part from any software, product or service of Facebook or any of its subsidiaries or affiliates, whether or not such claim is related to the Software, or (iii) by any party relating to the Software; or (b) that any right in any patent claim of Facebook is invalid or unenforceable."

This unconventional clause caused some controversy and debate in the React user community, because it could be interpreted to empower Facebook to revoke the license in many scenarios, for example, if Facebook sues the licensee prompting them to take "other action" by publishing the action on a blog or elsewhere. Many expressed concerns that Facebook could unfairly exploit the termination clause or that integrating React into a product might complicate a startup company's future acquisition.

Based on community feedback, Facebook updated the patent grant in April 2015 to be less ambiguous and more permissive:

"The license granted hereunder will terminate, automatically and without notice, if you (or any of your subsidiaries, corporate affiliates or agents) initiate directly or indirectly, or take a direct financial interest in, any Patent Assertion: (i) against Facebook or any of its subsidiaries or corporate affiliates, (ii) against any party if such Patent Assertion arises in whole or in part from any software, technology, product or service of Facebook or any of its subsidiaries or corporate affiliates, or (iii) against any party relating to the Software. [...] A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, or contributory infringement or inducement to infringe any patent, including a cross-claim or counterclaim."

The Apache Software Foundation considered this licensing arrangement to be incompatible with its licensing policies, as it "passes along risk to downstream consumers of our software imbalanced in favor of the licensor, not the licensee, thereby violating our Apache legal policy of being a universal donor", and "are not a subset of those found in the [Apache License 2.0], and they cannot be sublicensed as [Apache License 2.0].". In August 2017, Facebook dismissed the Apache Foundation's downstream concerns and refused to reconsider their license, and, the following month, WordPress decided to switch their Gutenberg and Calypso projects away from React.

License change

On September 23, 2017, Facebook announced that the following week, it would re-license Flow, Jest, React, and Immutable.js under a standard MIT License; the company stated that React was "the foundation of a broad ecosystem of open source software for the web", and that they did not want to "hold back forward progress for nontechnical reasons."

On September 26, 2017, React 16.0.0 was released with the MIT license. The MIT license change has also been backported to the 15.x release line with React 15.6.2.


15 Interesting JavaScript and CSS Libraries for July 2017 ...
src: tutorialzine.com


References


React JS Development รข€
src: www.nivasoftware.com


External links

  • Official website

Source of the article : Wikipedia

Comments
0 Comments