Inferno Book

0 views
Skip to first unread message

Curtis Cassel

unread,
Aug 3, 2024, 4:41:47 PM8/3/24
to flexemlunco

The main objective of the InfernoJS project is to provide the fastest possible runtime performance for web applications. Inferno excels at rendering real time data views or large DOM trees.

InfernoJS is actively tested with browsers listed below, however it may run well on older browsers as well.This is due to limited support of browser versions in recent testing frameworks. _notes/5.0.0.md

In these examples, JSX is used via the Inferno JSX Babel Plugin to provide a simple way to express Inferno virtual DOM. You do not need to use JSX, it's completely optional, you can use hyperscript or createElement (like React does).Keep in mind that compile time optimizations are available only for JSX.

Because performance is an important aspect of this library, we want to show you how to optimize your application even further.In the example below we optimize diffing process by using JSX $HasVNodeChildren and $HasTextChildren to predefine children shape compile time.In the MyComponent render method there is a div that contains JSX expression node as its content. Due to dynamic nature of Javascriptthat variable node could be anything and Inferno needs to go through the normalization process to make sure there are no nested arrays or other invalid data.Inferno offers a feature called ChildFlags for application developers to pre-define the shape of vNode's child node. In this example caseit is using $HasVNodeChildren to tell the JSX compiler, that this vNode contains only single element or component vNode.Now inferno will not go into the normalization process runtime, but trusts the developer decision about the shape of the object and correctness of data.If this contract is not kept and node variable contains invalid value for the pre-defined shape (fe. null), then application would crash runtime.There is also span-element in the same render method, which content is set dynamically through _getText() method. There $HasTextChildren child-flagfits nicely, because the content of that given "span" is never anything else than text.All the available child flags are documented here.

To tear down inferno application you need to render null on root element.Rendering null will trigger unmount lifecycle hooks for whole vDOM tree and remove global event listeners.It is important to unmount unused vNode trees to free browser memory.

Like React, Inferno also uses a light-weight synthetic event system in certain places (although both event systems differ massively). Inferno's event system provides highly efficient delegation and an event helper called linkEvent.

One major difference between Inferno and React is that Inferno does not rename events or change how they work by default. Inferno only specifies that events should be camel cased, rather than lower case. Lower case events will bypassInferno's event system in favour of using the native event system supplied by the browser. For example, when detecting changes on an element, in React you'd use onChange, with Inferno you'd use onInput instead (thenative DOM event is oninput).

linkEvent() is a helper function that allows attachment of props/state/context or other data to events without needing to bind() them or use arrow functions/closures. This is extremely useful when dealing with events in functional components. Below is an example:

In HTML, form elements such as , , and typically maintain their own state and update it based on user input.In Inferno, mutable state is typically kept in the state property of components, and only updated with setState().

We can combine the two by making the Inferno state be the "single source of truth". Then the Inferno component that renders a form alsocontrols what happens in that form on subsequent user input. An input form element whose value is controlled byInferno in this way is called a "controlled component".

Render a virtual node into the DOM in the supplied container given the supplied virtual DOM. If the virtual node was previously renderedinto the container, this will perform an update on it and only mutate the DOM as necessary, to reflect the latest Inferno virtual node.

createRenderer creates an alternative render function with a signature matching that of the first argument passed to a reduce/scan function. This allows for easier integration with reactive programming libraries, like RxJS and Most.

createVNode is used to create html element's virtual node object. Typically createElement() (package: inferno-create-element), h() (package: inferno-hyperscript) or JSX are used to createVNodes for Inferno, but under the hood they all use createVNode(). Below is an example of createVNode usage:

Clone and return a new Inferno VNode using a VNode as the starting point. The resulting VNode will have the original VNode's props with the new props merged in shallowly. New children will replace existing children. key and ref from the original VNode will be preserved.

forwardRef is a new mechanism to "forward" ref inside a functional Component.It can be useful if you have simple functional Components and you want to create reference to a specific element inside it.

This option can be used during development to create custom component comparator method.This option will be called on every Component update.It gets two parameters: lastVNode and nextVNode. When it returns true lastVNode will be replaced with nextVNode.If anything else than true is returned it falls to normal behavior.

If a component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements.In most cases, you can attach a ref to the DOM node and avoid using findDOMNode() at all. When render returns null or false, findDOMNode() returns null.If Component has rendered fragment it returns the first element.

By default, Inferno will run in development mode. Development mode provides extra checks and better error messages at the cost of slower performance and larger code to parse.When using Inferno in a production environment, it is highly recommended that you turn off development mode.

When building your application bundle, ensure process.env.NODE_ENV is replaced with string"development" or "production" based on the workflow.It is recommended to use ts-plugin-inferno for typescript TSX compilation and babel-plugin-infeno for javascript JSX compilation.

When building for development, you may want to use inferno.dev.esm.js. That bundle file contains ES6 exports for better tree-shaking support, improved error messages and added validation to help fixing possible issues during development.The file is found from package.json - dev:module entry point and the file is physically located in node_modules/inferno/dist/index.dev.esm.js.Remember that it is not recommended to use that file in production due to slower performance. For production usage use node_modules/inferno/dist/inferno.esm.js file.

Inferno always wants to deliver great performance. In order to do so, it has to make intelligent assumptions about the state of the DOM and the elements available to mutate. Custom namespaces conflict with this idea and change the schema of how different elements and attributes might work, so Inferno makes no attempt to support namespaces. Instead, SVG namespaces are automatically applied to elements and attributes based on their tag name.

InfernoLocation InformationAlternate NamesHellInhabitant(s)Infernal DemonsInferno (魔界 Makai, "Demon World"), otherwise referred to as Hell, is an important location in the Bayonetta universe. Created when the cosmos split into three parts, Inferno is the realm that houses the universal force of darkness. In the first Bayonetta game, it is only spoken and never seen in great detail. In the second game, Bayonetta 2, Bayonetta must travel into its depths in order to rescue Jeanne's soul after she is killed by Gomorrah. In both games, both Bayonetta and Jeanne are capable of summoning Inferno's inhabitants to battle against their angelic foes.

Only glimpses are seen of Inferno in the first game, mostly when demons come to claim the bodies of defeated Auditio when Rodin crosses into the realm when creating weapons for Bayonetta using the golden LPs collected throughout the game, or when the player chooses not to continue on the Game Over screen. It appears only as red, occasionally with twisted deformed hands reaching out or simply bloody in appearance from which screams and other indiscernible noises can be heard.

After Jeanne's soul is dragged into Inferno when trying to protect Bayonetta from a frenzied Gomorrah, Bayonetta vows to rescue her from its clutches. She learns from Rodin and Enzo that the entrance to Inferno, the actual Gates of Hell, resides on the sacred mountain of Fimbulventr that has so far never been found by human hands. Upon arriving in Noatun at the mountain's base, Bayonetta meets the mysterious child Loki, who claims that his powers will be needed in order to get to Inferno.

After a long journey and multiple clashes with a masked assailant and a self-titled prophet, Bayonetta eventually finds her way inside Inferno's Seventh Circle. Here, she sees it for what it truly is, a realm where demons run amok free from any control, and the very nature of the land is alive with monstrous plant growth and abominations. Inside, she also meets Rodin on a mission to capture a new demonic soul for his new weapon creation and he warns her not to smash up his target to save Jeanne.

Inside an infernal palace of vines, Bayonetta meets the demoness who has claimed Jeanne's soul for her own, Alraune. The demon tells her that there is no real escape from Inferno and battles the witch when she realizes who the intruder to her domain is. She is swiftly put down and Bayonetta is able to rescue her friend's soul and eventually gain a new weapon thank to Rodin at the same time.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages