![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A Library For Building User Interfaces.
<script src=dio.min.js></script>
<script src=https://unpkg.com/dio.js></script>
<script src=https://cdn.jsdelivr.net/npm/dio.js></script>
npm install dio.js --save
dio.render(
h('h1', 'Hello, world!'),
document.getElementById('root')
)
The following is an overview of the features afforded.
componentDidCatch
lifecycle.The following overloaded example presents a few features detailed above, namely – error boundaries, an implicit setState return, Promise setState and rendering Promises & Fragments.
class Input {
// error boundary
componentDidCatch (err, {componentStack, origin, message}) {
return {error: true}
}
// isomorphic async getInitialState
async getInitialState() {
return {value: 'Hi!'}
}
// implicit promise setState
async handleInput({target}, props, state) {
return {value: target.value}
}
// rendering promises
async render(props, {value, error}, context) {
// error state
if (error)
return h('h1', 'Something went wrong!')
// fragments
return [
h('input', {
value: value,
// bonus: events preserve "this" reference
onInput: this.handleInput
}),
h('p', value)
]
}
}
dio.render(h(Input))
Public react compatibility with an edge, this should mean that most react libraries can work as long as they does not make use of undocumented/public features, for example API's prefixed with unstable_
and vice-versa.
Affords the same ability as React to create your own renderer.
Events bubble in Portals as you would expect them to in the DOM, this avoids issues such as #11387 where bubbling through the virtual tree has some unintended behaviors.
In addition createPortal
supports string selectors and server-side rendering portals, a feature that might also make it into react: related issue.
In contrary to the assumed pros of event delegation a general purpose event delegation model is intentionally avoided to avoid the performance and memory pitfalls that come with re-implementing this at the level of abstraction that JavaScript affords, when considering the standard event bubbling behaviour that the host platform implements. That is to say, implementing such a system involves doing more work than the host platform would otherwise do.
Hydration goes the whole 9 yards to correct differences when hydrating, where React might otherwise error or ignore.
As opposed to React, the concept of developer warnings in a development build does not exist, The semantics that surround error boundaries help provide error messages when they occur at runtime.
React has a big community.
React has developer build warnings.
The ability to render Promises makes support for code-splitting and lazy loading straight forward when supported at the library level. The ability to use a Promise for initial state makes data fetching more declarative and the ability to update state with a promise allows you to deal with async services without cutting back on the declarative nature that is afforded to other first-class citizens.
class Input {
async getInitialState() {
return await fetch('service/')
}
async handleInput({target}, props, state) {
return await fetch('service/?value=${target.value}')
}
async render() {
return h('input', {
value: value,
onInput: this.handleInput
})
}
}
It is no surprise that declarative entry and exit animations in React are not at its best compared to other first-class citizens.
Allowing a means to declaratively define a delayed unmount that can enqueue exit animations before an unmount goes a long away in reducing the abstractions that go into dealing with this in its absence.
class Input {
async componentWillUnmount(node){
return new Promise((resolve) => {
node.animate([...], {...}).onfinish = resolve
})
}
async getInitialState() {
return {value: 'Initial value!'}
}
async handleInput({target}, props, state) {
return {value: target.value}
}
async render() {
return h('input', {
ref: 'input'
value: value,
onInput: this.handleInput
})
}
}
React events outside of createClass
components have an infamous relationship with .bind
. The implementation details allow us to avoid this relationship and additionally allow multiple event handlers for a single event.
class Input {
handleSubmit(e, props, state) {
this instanceof Input
}
handleReset(e, props, state) {
this instanceof Input
}
render() {
return h('form', {
onSubmit: [this.handleSubmit, this.handleReset]
})
}
}
Support for async iterators works much like regular iterators, but instead of a sequence of elements involve a sequence of states. This allows synchronous designs to emerge from otherwise asynchronous programs.
class Suspense {
async *render() {
yield 'Loading...'
const data = await fetch('./')
yield h('pre', JSON.stringify(data))
}
}
Rendering promises/awaiting promise states is afforded to components within the context of renderToNodeStream
allowing both the previous example uses of async getInitialState
and Async Generators to render just as well when delivering a rendered payload from a server.
Custom components are components that instantiate their own host elements. Within a DOM context a custom element constructor might fall under this group of components.
class WordCount extends HTMLElement {
// ...
}
customElements.define('word-count', WordCount)
This allows us to render the given WordCount
custom element without afore knowledge of its defined localName
.
render(h(WordCount))
FAQs
A Library For Building User Interfaces.
The npm package dio.js receives a total of 15 weekly downloads. As such, dio.js popularity was classified as not popular.
We found that dio.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.