New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

html2jsx-loader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html2jsx-loader

html to jsx loader for webpack

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

html2jsx-loader

Webpack loader module that exports HTML as React JSX class. I created this loader to help webmasters work with layouts in friendly html environment. HTML can be then just copied by front-end developer to proper component or container for further development.

Usage

Documentation: Using loaders

Installation

npm i html2jsx-loader

Examples

Add the html2jsx-loader to your Webpack configuration:

{
    resolve: {
        extensions: ['','.js','.html']
    }
    ...
    module: {
        loaders: [{
            test: /.html$/
            , loader: 'babel!htmltojsx'
        }
    ]}
    ...
}

Now you can write raw HTML (e.g. Layout1.html) and webpack will automatically convert the content of this file to a React component.

Finally, you can reference this component in your JavaScript code as follows:

const Layout1 = require('./Layout1');
const Layout2 = require('./Layout2');

//Layout1 is not HTML but ReactJS class.
const routes = (
    <Route path="/" component={RootLayout}>
        <Route path = "layout1" component = {Layout1} />
        <Route path = "layout2" component = {Layout2} />
        ...

Keywords

html

FAQs

Package last updated on 14 Dec 2016

Did you know?

Socket

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.

Install

Related posts