Building AR & VR Applications using React Native

  • We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads.
  • You can change your ad preferences anytime.

These are my slides from the React Amsterdam talk on building Augmented Reality & Virtual Reality applications using React Native & Viro Media
Continue reading “Building AR & VR Applications using React Native”

Snapshot Tests in React Using Jest

  • Today we’re talking about snapshot tests using Jest.
  • When writing snapshot tests using jest, you should basically just follow the next template: – – You use to create a component with desired props, transform it to JSON and then check if it matches a snapshot.
  • Here’s a more concrete example – let’s say we have a dummy component called , for which we want to write a snapshot test: – – For our Input component, it can look something like this: – – To run the test, you just need to type command in terminal….
  • Output snapshot file will be created, and when running the test next time, jest will compare that output snapshot file to our updated component.
  • Keep in mind that all of these output snapshot files should be committed alongside the modules they are covering and their tests, as they are part of the test.

Continue reading “Snapshot Tests in React Using Jest”

✏️ Draw 2D primitives in sketchy style with React #reactjs

✏️ Draw 2D primitives in sketchy style with React #reactjs

  • and one wrapper component called Paper which serves as a canvas on which these primitives are drawn.
  • Here is a basic example – – – You can also render the primitives when working with ReactDOM as this just renders to a canvas node.
  • ( )) create function has already rendered the canvas node.
  • So now you can continue to use React with ReactDOM as you used to.
  • Make changes directly to the component.

react-handy-renderer – ✏️ Draw 2D primitives in sketchy style with React
Continue reading “✏️ Draw 2D primitives in sketchy style with React #reactjs”

New context API by acdlite · Pull Request #11818 · facebook/react · GitHub

  • Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
  • Already on GitHub?
  • Sign in to your account

react – A declarative, efficient, and flexible JavaScript library for building user interfaces.
Continue reading “New context API by acdlite · Pull Request #11818 · facebook/react · GitHub”

Understanding The React Source Code — Initial Rendering (Simple Component) I

  • var childrenLength = arguments.length — 2; if (childrenLength === 1) { props.children = children; // scr: one child is stored as object } else if (childrenLength 1) { var childArray = Array(childrenLength); for (var i = 0; i childrenLength; i++) { childArray[i] = arguments[i + 2]; // scr: multiple children…
  • …var ReactElement = function(type, key, ref, self, source, owner, props) { // This tag allow us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE,// Built-in properties that belong on the element type: // scr: ————– ‘h1’ key: // scr: ————– not of interest for now ref: // scr:…
  • The name TopLevelWrapper explains what it does — wrap the top level element (of the component tree passed through render()):An important definition here is that of TopLevelWrapper, I type three stars here *** for you to CTL-f, as you might need to come back to this definition later:…var TopLevelWrapper = function() {…
  • The only line that is effective before the logic processes to next step is… var nextWrappedElement = { child: nextElement, that it should be easy to see how the target object of this step is constructed with React.createElement, the function we just examined in the last a `ReactCompositeComponent` using `ReactElement[2]`The…
  • In our context, it checks the ReactElement[2]’s type (i.e., TopLevelWrapper) and creates a ReactCompositeComponent accordingly.function shouldHaveDebugID) { var instance;… } else if (typeof node === ‘object’) { var element = node; var type = element.type;… // Special case string values if (typeof element.type === ‘string’) {… } else if {……

UI updating, in its essential, is data change. React offers a straightforward and intuitive way to program front-end Apps as all the moving parts are converged in the form of states. Code review of…
Continue reading “Understanding The React Source Code — Initial Rendering (Simple Component) I”

Understanding The React Source Code — Initial Rendering (Class Component) IV

Understanding The #ReactJS Source #Code IV:  via @hackernoon #Javascript

  • /App.css’;class App extends Component { constructor(props) { super(props); this.state = { desc: ‘start’, }; }render() { return ( div className=”App” div className=”App-header” img src=”main.jpg” className=”App-logo” alt=”logo” / h1 “Welcom to React” /h1 /div p className=”App-intro” { this.state.desc } /p /div ); }}export default App;App@App.jsAs mentioned, the component above is rendered…
  • /App.css’;class App extends Component { constructor(props) { super(props); this.state = { desc: ‘start’, }; } render() { return React.createElement( ‘div’, { className: ‘App’ }, React.createElement( ‘div’, { className: ‘App-header’ }, React.createElement( ‘img’, { src: “main.jpg”, className: ‘App-logo’, alt: ‘logo’ } ), React.createElement( ‘h1’, null, ‘ “Welcom to React” ‘ )…
  • Initialize designated data structure:The step is the same as well:1) ReactDOMContainerInfo[ins] represents the container DOM element, TopLevelWrapper is instantiated (TopLevelWrapper[ins]) and is set to alongside the initialization of other properties;3) Again, mountComponentIntoNode is the cross point of upper and lower half, within which returns a complete DOMLazyTree that can be…
  • After those operations complete, the logic processes to the first ramification that is specific to class a `ReactCompositeComponent` from `ReactElement[1]`This step strips the wrapper and creates another ReactCompositeComponent instance to reflect the class component, App.The designated data structure:The call stack in | | | /* we are here */ |…
  • _renderedComponent = child; var markup = transaction, hostParent, hostContainerInfo, debugID); // scr: 3)…// scr: DEV code return designated data structure:The call stack in | | | upper half | /* we are here */ | |Same as in {post two}, the most important task of this step is to instantiate…

Understanding The React Source Code I
Understanding The React Source Code II
Understanding The React Source Code III
Understanding The React Source Code IV (this one) We have completed the rendering…
Continue reading “Understanding The React Source Code — Initial Rendering (Class Component) IV”

What’s New With Server-Side Rendering in React 16 – Hacker Noon

What’s New With Server-Side Rendering in React 16:  by @xander76 #JavaScript #ReactJS #NodeJS

  • Naturally, this feature is also supported by React 16’s server-side rendering.So, you can now server-render components that look like this:class MyArrayComponent extends React.Component { render() { return [ div key=”1″first element/div, div key=”2″second element/div ]; }}class MyStringComponent extends React.Component { render() { return “hey there”; }}class MyNumberComponent extends React.Component {…
  • To learn more about this feature, read Dan Abramov’s post on the React blog about the change.React 16 SSR Doesn’t Support Error Boundaries or PortalsThere are two new features in the React 16 client-side renderer that are unfortunately not supported in the server-side renderer: Error Boundaries and Portals.
  • If for any reason there’s a mismatch, React raises a warning in development mode and replaces the entire tree of server-generated markup with HTML that has been generated on the client.In React 16, though, the client-side renderer uses a different algorithm to check that the server-generated markup is correct.
  • And when the client-side renderer in React 16 detects a markup mismatch, it only attempts to change the HTML subtree that doesn’t match, rather than the entire HTML tree.Generally, this change shouldn’t have much effect for end users, except for one fact: React 16 doesn’t fix mismatched SSR-generated HTML attributes…
  • This performance optimization means that you will need to make extra sure that you fix any markup mismatch warnings you see in your app in development mode.React 16 Doesn’t Need To Be Compiled For Best PerformanceIn React 15, if you used SSR straight out of the box, performance was less…

There are lots of exciting new bits (most notably the Fiber rewrite), but personally, I’m most excited about React 16’s many improvements that have been made to server-side rendering. Let’s take a…
Continue reading “What’s New With Server-Side Rendering in React 16 – Hacker Noon”

Lottie – Render After Effects animations natively on Web, Android and iOS, and React Native

Lottie - Render After Effects animations natively on Web, Android and iOS, and React Native

  • Lottie is a mobile library for Web, and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!
  • Install the zxp manually following the instructions here: Skip directly to “Install third-party extensions” – – Or you can use the script file from here: Or get it directly from the AE plugin clicking on Get Player – – Here’s a video tutorial explaining how to export a basic animation…
  • — with 1 optional parameter name to target a specific animation – – bodymovin.stop() — with 1 optional parameter name to target a specific animation – – bodymovin.setSpeed() — first argument speed (1 is normal speed) — with 1 optional parameter name to target a specific animation – – bodymovin.setDirection()…
  • — with 1 optional parameter name to target a specific animation – – bodymovin.searchAnimations() — looks for elements with class “bodymovin” – – bodymovin.loadAnimation() — Explained above.
  • you can also use addEventListener with the following events: – – Doing this you will have to handle the canvas clearing after each frame – – Another way to load animations is adding specific attributes to a dom element.

lottie-web – Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/
Continue reading “Lottie – Render After Effects animations natively on Web, Android and iOS, and React Native”

Tutorial on how to make a custom React renderer #ReactJS

Tutorial on how to make a custom React renderer  #ReactJS

  • This is a small tutorial on how to build your custom React renderer and render the components to the host environment you need.
  • In part three, we will build a function that will parse the input component and will return the output (rendered children and props).
  • In part four, we will create a render method which will render our input component.
  • We will create a custom renderer that will render a React component to a word document.
  • It generates a output stream and not a file.

Making-a-custom-React-renderer – Tutorial on how to make a custom React renderer
Continue reading “Tutorial on how to make a custom React renderer #ReactJS”

react-tv now supports @reactjs 16.0.0 and use React-Reconciler! Thanks to @NTulswani :)

  • React-TV is a ecosystem for React Application for TVs (from the renderer to CLI for pack/build applications) focused now on WebOS and SmartTV.
  • The mission of React-TV is build & develop fast for TVs.
  • The strategy is step in the renderer: Applying reactive concepts to unblock the processing on renderer layer, plug the TV’s keyListener, avoid React.createElement (which cost a lot)[…] – – In addition: Unify the build for multiple TV platforms.
  • When building a cross-platform tv app, you’ll want to re-use as much code as possible.
  • React-TV provides module to easily organize your code and separate it by platform: – – WebOS, also known as Open WebOS or LG WebOS, (previously known as HP WebOS and Palm WebOS, stylized as webOS) is a Linux kernel-based multitasking operating system for smart devices such as Smart TVs and…

react-tv – [WIP] React development for TV (Renderer for low memory applications and Packager for WebOS, Tizen, Orsay) 📺
Continue reading “react-tv now supports @reactjs 16.0.0 and use React-Reconciler!
Thanks to @NTulswani :)”