loading...
loading...
loading...
loading...
Get it from deno.land/x/nano_jsx and have a look at the deno example.
loading...
It is important to know that the beauty of Nano JSX is, that it is so close to the DOM, that you can easily mix Vanilla JS and Nano JSX however you want.
You can:
render()
multiple Nano JSX application on the same page.render()
inside a Component to render another Nano JSX Component to
another DOM Element.
Please have a closer look at the code below. You would probably never do this in a framework like React, but in Nano JSX you have the freedom to use JSX however you like. All you see here is valid. If you use Nano JSX cleverly, you will love its flexibility and make fast apps.
loading...
These methods are called in the following order when a class Component is created and rendered:
constructor()
willMount()
render()
didMount()
When calling this.update()
on a class Component, these methods are called in the
following order:
willUpdate()
render()
didUpdate()
This method is called when a class Component has unmounted (detached from the DOM):
didUnmount()
In SSR, non of the lifecycle hook are called.
Nano JSX does never update a class Component automatically. You have to call
update()
manually. On every component you call
update()
, the root element needs to be a DOM element or a Fragment of DOM
elements.
The update(update?: any)
method can receive an optional argument. When provided
it will be passed as parameter to the Components render(param)
function and can
be accessed inside it.
You can simply pass props to children as you are used to in other JSX libraries.
loading...
loading...
loading...
loading...
loading...
Nano JSX escapes text as a default behavior, this behavior protects your application from crises such as XSS attacks, but sometimes you want not to escape text. Nano JSX provides API for that time as well as React.
dangerouslySetInnerHTML, this naming is same as React, allows you to set HTML directly.
Nano JSX does not escape a text node in <script />
,
<style />
, <noscript />
, and also all
content in <Helmet />
for usability.
loading...
A more readable alternative style:
loading...
Nano JSX offers an optional withStyles()
HOC (Higher Order Component) to style
your Components.
You can simply pass your css as a string, or use an appropriate loader, for Webpack or similar, to import css or sass/scss files.
You can pass to withStyles()
an array of (or separated by a comma):
string
toString()
string
Info:
For an example configuration using Webpack and withStyles().
with Sass/SCSS,
have a look at the
Nano JSX Template
This example demonstrates how to render a functional Component with pre-defined styles using
withStyles()
. For a more in depth example, check out the
withStyles example.
loading...
You can easily convert your Components to WebComponents via defineAsCustomElements().
loading...
loading...