8.2.3 • Published 5 months ago

inferno-compat v8.2.3

Weekly downloads
4,026
License
MIT
Repository
-
Last release
5 months ago

inferno-compat

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:

  • ClassName is copied to props
  • Children is copied to props (for html vNodes too)
  • String refs are supported
  • Empty props are always created for element vNodes
  • You can create Components based on string
  • findDOMNOde -method is available
  • Iterable data structures are supported
  • Children.(map/forEach/count/only/toArray) - methods are available
  • Html properties are transformed to inferno compatible format
  • Some form events (fe: onChange) are transformed to native alternative
  • PureComponent is available
  • unstable_renderSubtreeIntoContainer - method is available
  • DOM - factory is available
  • unmountComponentAtNode - method is available its same as "render(null, container)"

How to install?

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.

What is currently supported?

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

Usage with Webpack

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'
		}
	}
}

Usage with Babel

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"
            }
        }]
    ]
}

Usage with Browserify

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"
        }
    }
    // ...
}

Once Aliased

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"));
5.6.3

5 months ago

8.2.3

1 year ago

8.2.2

1 year ago

8.2.1

2 years ago

8.2.0

2 years ago

8.1.1

2 years ago

8.1.0

2 years ago

8.0.6

2 years ago

8.0.5

2 years ago

8.0.4

2 years ago

8.0.0-alpha.6

3 years ago

8.0.1

3 years ago

8.0.0

3 years ago

8.0.3

2 years ago

8.0.2

2 years ago

8.0.0-alpha.5

3 years ago

8.0.0-alpha.4

3 years ago

8.0.0-alpha.3

3 years ago

8.0.0-alpha.2

3 years ago

7.4.11

3 years ago

8.0.0-alpha.1

3 years ago

8.0.0-alpha.0

3 years ago

7.4.10

3 years ago

7.4.9

3 years ago

7.4.8

4 years ago

7.4.7

4 years ago

5.6.2

4 years ago

7.4.6

4 years ago

7.4.4

4 years ago

7.4.5

4 years ago

7.4.3

4 years ago

7.4.2

5 years ago

7.4.1

5 years ago

7.4.0

5 years ago

7.3.3

5 years ago

7.3.2

5 years ago

7.3.1

5 years ago

7.3.0

5 years ago

7.2.1

5 years ago

7.2.0

5 years ago

7.1.13

6 years ago

7.1.12

6 years ago

7.1.11

6 years ago

7.1.10

6 years ago

7.1.9

6 years ago

7.1.8

6 years ago

7.1.7

6 years ago

7.1.6

6 years ago

7.1.5

6 years ago

7.1.4

6 years ago

7.1.3

6 years ago

7.1.2

6 years ago

7.1.1

6 years ago

7.1.0

6 years ago

7.0.5

6 years ago

7.0.4

6 years ago

7.0.2

6 years ago

7.0.1

6 years ago

7.0.0

6 years ago

6.3.1

6 years ago

6.3.0

6 years ago

6.2.1

6 years ago

6.2.0

6 years ago

6.1.5

6 years ago

6.1.4

6 years ago

6.1.3

6 years ago

6.1.2

6 years ago

6.1.1

6 years ago

6.1.0

6 years ago

6.0.3

6 years ago

6.0.2

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

6.0.0-rc.5

6 years ago

6.0.0-rc.3

6 years ago

6.0.0-rc.1

6 years ago

6.0.0-rc.0

6 years ago

6.0.0-alpha.3

6 years ago

6.0.0-alpha.2

6 years ago

6.0.0-alpha.1

6 years ago

5.6.1

6 years ago

5.6.0

6 years ago

6.0.0-alpha.0

6 years ago

5.5.0

6 years ago

5.4.2

6 years ago

5.4.1

6 years ago

5.4.0

6 years ago

5.3.0

6 years ago

5.2.0

6 years ago

5.1.1

7 years ago

5.1.0

7 years ago

5.0.6

7 years ago

5.0.5

7 years ago

5.0.4

7 years ago

5.0.3

7 years ago

5.0.2

7 years ago

5.0.1

7 years ago

5.0.0

7 years ago

5.0.0-2

7 years ago

5.0.0-1

7 years ago

5.0.0-0

7 years ago

4.0.8

7 years ago

4.0.7

7 years ago

4.0.6

7 years ago

4.0.5

7 years ago

4.0.4

7 years ago

4.0.3

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

4.0.0-21

7 years ago

4.0.0-20

7 years ago

4.0.0-19

7 years ago

4.0.0-18

7 years ago

4.0.0-17

7 years ago

4.0.0-16

7 years ago

4.0.0-15

7 years ago

4.0.0-14

7 years ago

4.0.0-13

7 years ago

4.0.0-12

7 years ago

4.0.0-11

7 years ago

4.0.0-10

7 years ago

4.0.0-9

7 years ago

4.0.0-8

7 years ago

4.0.0-7

7 years ago

4.0.0-6

7 years ago

4.0.0-5

7 years ago

4.0.0-4

7 years ago

4.0.0-3

7 years ago

4.0.0-2

7 years ago

4.0.0-1

7 years ago

4.0.0-0

7 years ago

3.10.1

7 years ago

3.10.0

7 years ago

3.9.0

7 years ago

3.8.2

7 years ago

3.8.1

7 years ago

3.8.0

7 years ago

3.7.1

7 years ago

3.7.0

7 years ago

3.6.4

7 years ago

3.6.3

7 years ago

4.0.0-alpha1

7 years ago

3.6.1

8 years ago

3.6.0

8 years ago

3.5.4

8 years ago

3.5.3

8 years ago

3.5.2

8 years ago

3.5.1

8 years ago

3.5.0

8 years ago

3.4.4

8 years ago

3.4.3

8 years ago

3.4.2

8 years ago

3.4.0

8 years ago

3.3.1

8 years ago

3.3.0

8 years ago

3.2.2

8 years ago

3.2.1

8 years ago

3.2.0

8 years ago

3.1.2

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

3.0.6

8 years ago

3.0.5

8 years ago

3.0.4

8 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.0.0

8 years ago

1.6.2

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.6

8 years ago

1.5.5

8 years ago

1.5.4

8 years ago

1.5.3

8 years ago

1.5.2

8 years ago

1.5.1

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.3.0-rc.10

8 years ago

1.3.0-rc.9

8 years ago

1.3.0-rc.8

8 years ago

1.3.0-rc.7

8 years ago

1.3.0-rc.6

8 years ago

1.3.0-rc.5

8 years ago

1.3.0-rc.4

8 years ago

1.3.0-rc.3

8 years ago

1.3.0-rc.2

8 years ago

1.3.0-rc.1

8 years ago

1.3.0-rc.0

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0-beta45

8 years ago

1.0.0-beta44

8 years ago

1.0.0-beta43

8 years ago

1.0.0-beta42

8 years ago

1.0.0-beta41

8 years ago

1.0.0-beta40

8 years ago

1.0.0-beta39

8 years ago

1.0.0-beta38

8 years ago

1.0.0-beta37

8 years ago

1.0.0-beta36

8 years ago

1.0.0-beta35

8 years ago

1.0.0-beta34

8 years ago

1.0.0-beta33

8 years ago

1.0.0-beta32

8 years ago

1.0.0-beta31

8 years ago

1.0.0-beta30

8 years ago

1.0.0-beta29

8 years ago

1.0.0-beta28

8 years ago

1.0.0-beta27

8 years ago

1.0.0-beta26

8 years ago

1.0.0-beta25

8 years ago

1.0.0-beta24

8 years ago

1.0.0-beta23

8 years ago

1.0.0-beta22

8 years ago

1.0.0-beta21

8 years ago

1.0.0-beta20

8 years ago

1.0.0-beta19

8 years ago

1.0.0-beta18

8 years ago

1.0.0-beta17

8 years ago

1.0.0-beta16

8 years ago

1.0.0-beta15

8 years ago

1.0.0-beta14

8 years ago

1.0.0-beta13

8 years ago

1.0.0-beta12

8 years ago

1.0.0-beta11

8 years ago

1.0.0-beta10

8 years ago

1.0.0-beta9

8 years ago

1.0.0-beta8

8 years ago

1.0.0-beta7

8 years ago

1.0.0-beta6

8 years ago

1.0.0-beta5

8 years ago

1.0.0-beta4

8 years ago

1.0.0-beta3

8 years ago

1.0.0-beta2

8 years ago

1.0.0-beta1

8 years ago

1.0.0-alpha11

8 years ago

1.0.0-alpha10

8 years ago

1.0.0-alpha9

8 years ago

1.0.0-alpha8

8 years ago

1.0.0-alpha7

8 years ago

1.0.0-alpha6

8 years ago

1.0.0-alpha5

8 years ago

1.0.0-alpha4

8 years ago

1.0.0-alpha3

8 years ago

1.0.0-alpha2

8 years ago

0.7.27

8 years ago

0.7.26

8 years ago

0.7.25

8 years ago

0.7.24

8 years ago

0.7.23

8 years ago

0.7.22

8 years ago

0.7.21

8 years ago

0.7.20

8 years ago

0.7.18

8 years ago

0.7.17

8 years ago

0.7.16

8 years ago

0.7.15

8 years ago

0.7.14

8 years ago