npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

domvm-jsx

v1.0.3

Published

This package supplies the el function defined in the [Using JSX with domvm wiki](https://github.com/domvm/domvm/wiki/JSX).

Downloads

6

Readme

domvm-jsx

This package supplies the el function defined in the using JSX with domvm wiki.


Using domvm and JSX

While not all of domvm's features can be accommodated by JSX syntax, it's possible to cover a fairly large subset via a defineElementSpread pragma. Please refer to demos and examples in the JSX wiki.

Quick start

  • install via npm/yarn
    npm install domvm-jsx --save

Combining domvm and JSX with webpack and babel

  • package.json
    ...
    
    "devDependencies": {
        "webpack": "^3.8.1",
        "babel-core": "^6.26.0",
        "babel-loader": "^7.1.2",
        "babel-preset-env": "^1.6.1",
        "babel-plugin-transform-react-jsx": "^6.24.1"
    },
    "dependencies": {
        "domvm": "^3.3.3",
        "domvm-jsx": "^1.0.0"
    }
    
    ...
  • webpack.config.js
    ...
    
    module: {
        loaders: [
            {
                test: /\.(jsx|js)$/,
                loader: ['babel-loader']
            }
        ]
    }
    
    ...
  • babel.rc
    {
        "presets": [
            "env"
        ],
        "plugins": [
            [
                "transform-react-jsx",
                {
                    "pragma": "el"
                }
            ]
        ]
    }
  • your-project-file.js
    ...
    
    // jsx entry function
    const el = require('domvm-jsx');
    
    // define a component to be included via JSX (*note that components must start with a capital to differentiate them from element tags)
    const Component = (vm) => {
    
        return (vm) => {
    
            return (
                <div>{vm.data.step}{vm.data.children}</div>
            );
        };
    };
    
    // create a view using JSX and bind component
    const view = function (vm) {
        let step = 0;
    
        setInterval(() => {
            step = step +1;
            vm.redraw();
        }, 1000);
    
        return function() {
    
            /* has own content */
            return (
                <div>
                    {/* includes the component as a child */}
                    <Component
                      name='foo'
                      step={step}
                    >
                        <div>I'm a child</div>
                </div>
            );
        };
    };
    
    // create a vm from the view
    const vm = domvm.createView(view);
    
    // mount to the dom
    vm.mount(document.getElementById('root'));
    
    ...
    

Acknowledgements

See discussion here

License