Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
react-reconciler
Advanced tools
The react-reconciler package is a framework for building custom React renderers. It provides the core algorithms that React uses for reconciliation, allowing developers to create their own renderers for different target environments beyond what React supports out of the box (e.g., the web or native mobile). This package is an under-the-hood tool primarily intended for advanced use cases where you need to create a custom rendering environment.
Creating a Custom Renderer
This code sample demonstrates how to start creating a custom renderer using react-reconciler. You define methods like `createInstance` for creating instances of components and `createTextInstance` for handling text. The host config object passed to `ReactReconciler` includes a variety of methods for managing instances, updates, and more.
const MyRenderer = ReactReconciler({
now: Date.now,
createInstance: (type, props) => {
// Create instance of a component
},
createTextInstance: (text) => {
// Create text instance
},
// Other host config methods...
});
Scheduling Updates
This example shows how to schedule updates to the container using your custom renderer. The `updateContainer` method is used to apply updates to the container, which in this case is a custom object you manage. This method is part of what allows React's declarative API to work with your custom rendering logic.
const container = {}; // Your container object
MyRenderer.updateContainer(<App />, container, null, () => {
console.log('Rendered with MyRenderer');
});
Preact is a fast 3kB alternative to React with the same modern API. While not a direct alternative to react-reconciler, it offers a different approach to building user interfaces with a smaller footprint. Preact can be used to build custom renderers, but its primary use case is as a React alternative for building web applications.
Inferno is another high-performance alternative to React that focuses on speed and performance. Similar to Preact, Inferno is not a direct alternative to react-reconciler but offers a different approach to building UIs with an emphasis on performance. Inferno includes its own mechanisms for creating custom renderers, making it a potential alternative for performance-critical applications.
This is an experimental package for creating custom React renderers.
Its API is not as stable as that of React, React Native, or React DOM, and does not follow the common versioning scheme.
Use it at your own risk.
var Reconciler = require('react-reconciler');
var HostConfig = {
// You'll need to implement some methods here.
// See below for more information and examples.
};
var MyRenderer = Reconciler(HostConfig);
var RendererPublicAPI = {
render(element, container, callback) {
// Call MyRenderer.updateContainer() to schedule changes on the roots.
// See ReactDOM, React Native, or React ART for practical examples.
}
};
module.exports = RendererPublicAPI;
A "host config" is an object that you need to provide, and that describes how to make something happen in the "host" environment (e.g. DOM, canvas, console, or whatever your rendering target is). It looks like this:
var HostConfig = {
createInstance(type, props) {
// e.g. DOM renderer returns a DOM node
},
// ...
supportsMutation: true, // it works by mutating nodes
appendChild(parent, child) {
// e.g. DOM renderer would call .appendChild() here
},
// ...
};
The full list of supported methods can be found here. For their signatures, we recommend looking at specific examples below.
The React repository includes several renderers. Each of them has its own host config.
The examples in the React repository are declared a bit differently than a third-party renderer would be. In particular, the HostConfig
object mentioned above is never explicitly declared, and instead is a module in our code. However, its exports correspond directly to properties on a HostConfig
object you'd need to declare in your code:
If these links break please file an issue and we’ll fix them. They intentionally link to the latest versions since the API is still evolving. If you have more questions please file an issue and we’ll try to help!
0.12.0 (October 28, 2014)
key
and ref
moved off props object, now accessible on the element directlyReact.__internals
is removed - it was exposed for DevTools which no longer needs accessReact.createFactory
first. This is handled for you when using JSX.{...}
) introduced to deprecate this.transferPropsTo
acceptCharset
, classID
, manifest
React.renderComponent
--> React.render
React.renderComponentToString
--> React.renderToString
React.renderComponentToStaticMarkup
--> React.renderToStaticMarkup
React.isValidComponent
--> React.isValidElement
React.PropTypes.component
--> React.PropTypes.element
React.PropTypes.renderable
--> React.PropTypes.node
React.isValidClass
instance.transferPropsTo
false
from event handlers to preventDefaultReact.createFactory
key={null}
to assign implicit keysevent.getModifierState
as case sensitiveevent.charCode
list
updates correctly nowscrollLeft
, scrollTop
removed, these should not be specified as propsReact.addons.batchedUpdates
added to API for hooking into update cycleReact.addons.update
uses assign
instead of copyProperties
which does hasOwnProperty
checks. Properties on prototypes will no longer be updated correctly.@jsx React.DOM
no longer required{...}
) operator introduced to allow easier use of propsFAQs
React package for creating custom renderers.
The npm package react-reconciler receives a total of 913,582 weekly downloads. As such, react-reconciler popularity was classified as popular.
We found that react-reconciler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.