Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
inferno-compat
Advanced tools
This module is a compatibility layer that makes React-based modules work with Inferno, without any code changes.
It provides the same exports as react
and react-dom
, meaning you can use your build tool of choice to drop it in where React is being depended on.
Do note however, as with almost all compatability layer libraries, there is an associated cost of extra overhead. As such, you should never expect native Inferno performance when using inferno-compat
.
You might not always need the inferno-compat
package. Just the alias to Inferno might be enough.
Inferno-compat adds the following features:
As in React:
options.reactStyles = false;
findDOMNOde
-method is availableChildren.(map/forEach/count/only/toArray)
- methods are availableunstable_renderSubtreeIntoContainer
- method is availableDOM
- factory is availableunmountComponentAtNode
- method is available its same as "render(null, container)"Inferno-compat does not automatically install all its features. For example: If you need createElement support you should also install inferno-create-element
.
All packages:
npm install --save inferno
npm install --save inferno-compat
npm install --save inferno-clone-vnode
npm install --save inferno-create-class
npm install --save inferno-create-element
If you use React/lib/ReactCSSTransitionGroup.js
install inferno-transition-group
package.
If you use React/lib/ReactCSSTransitionGroup.js
install rc-css-transition-group-modern
package.
react
React.createClass
React.createElement
React.cloneElement
React.Component
React.PureComponent
React.PropTypes
React.Children
React.isValidElement
Note: Inferno will not currently validate PropTypes
react-dom
ReactDOM.render
ReactDOM.hydrate
ReactDOM.unmountComponentAtNode
ReactDOM.findDOMNode
React.DOM
React.createFactory
Using inferno-compat
with Webpack is easy.
All you have to do is add an alias for react
and react-dom
:
{
resolve: {
alias: {
'react': 'inferno-compat',
'react-dom': 'inferno-compat'
}
}
}
Install the Babel plugin for module aliasing: npm install --save-dev babel-plugin-module-resolver
.
Babel can now alias react
and react-dom
to inferno
by adding the following to your .babelrc
file:
{
"plugins": [
["module-resolver", {
"root": ["."],
"alias": {
"react": "inferno-compat",
"react-dom": "inferno-compat"
}
}]
]
}
Using inferno-compat
with Browserify is as simple as installing and configuring aliasify.
First, install it: npm install --save-dev aliasify
... then in your package.json
, configure aliasify to alias react
and react-dom
:
{
// ...
"aliasify": {
"aliases": {
"react": "inferno-compat",
"react-dom": "inferno-compat"
}
}
// ...
}
With the above Webpack or Browserify aliases in place, existing React modules should work nicely:
import React from 'react';
import ReactDOM from 'react-dom';
class Foo extends React.Component {
propTypes = {
a: React.PropTypes.string.isRequired
};
render() {
let { a, b, children } = this.props;
return <div {...{a,b}}>{ children }</div>;
}
}
ReactDOM.render((
<Foo a="a">test</Foo>
), document.getElementById("app"));
FAQs
Provides a compatibility with React codebases
The npm package inferno-compat receives a total of 20,535 weekly downloads. As such, inferno-compat popularity was classified as popular.
We found that inferno-compat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
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.