1.0.10 • Published 7 years ago

react-declaration-loader v1.0.10

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

react-declaration-loader

Populates JSX sources with React declaration.

Since JSX converts your XML kind of

return <span>{userStatus}</span>;

to pure javascript code like

return React.createElement('span', null, userStatus);

it still doesn't care whether you declared React in your code or not.

So react-declaration-loader is doing it's job. If it detects references to React without appropriate declaration it populates your source with needed one.

Thus you may write out your code just like this

import {Component} from 'react';
export class MyComponent extends Component {
    render() {
        let {message} = this.props;
        return <h1>{message}</h1>;
    }
}

Usage

npm install react-declaration-loader --save

Add react-declaration-loader to your webpack.config.js

//...
module: {
    loaders: [
        {
            test: /.jsx?$/,
            loaders: ['react-declaration-loader', 'babel-loader']
        },
//...

Make sure react-declaration-loader to handle your sources after they were transpiled to pure javascript code with babel-loader (or sth.) because it can not resolve JSX it self.

Address your self to example for details.

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago