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

snabbdom-on-rails

v0.0.2

Published

snabbdom-on-rails JavaScript for react_on_rails Ruby gem

Downloads

11

Readme

snabbdom-on-rails

npm version

snabbdom-on-rails JavaScript for react_on_rails Ruby gem allowing you to use snabbdom instead of react as your virtual dom.

Install

npm install snabbdom-on-rails --save

Getting Started

The setup for using snabbdom-on-rails is the same as for react_on_rails, you will simply need to swap the react-on-rails and react node modules for snabbdom, snabbdom-jsx and snabbdom-on-rails in your package.json.

  1. Add the following to your Gemfile and bundle install.
gem "react_on_rails", "~> 5"
  1. Commit this to git (you cannot run the generator unless you do this).

  2. Run the generator with a simple "Hello World" example (more options below):

rails generate react_on_rails:install
  1. As mentioned, remove react, react-router and react-on-rails node modules for snabbdom, snabbdom-jsx and snabbdom-on-rails in your package.json. snabbdom-to-html also if you need server rendering.
"snabbdom": "^0.5.3",
"snabbdom-jsx": "^0.3.1",
"snabbdom-to-html": "^2.1.3",
"snabbdom-on-rails": "^0.0.1",
  1. Bundle and NPM install. Make sure you are on a recent version of node. Please use at least Node v5. Bundle is for adding execJs. You can remove that if you are sure you will not server render.
bundle && npm install
  1. Start your Rails server:
foreman start -f Procfile.dev
  1. Visit localhost:3000/hello_world

Usage

An example below of rendering a simple component/function with snabbdom-on-rails. There is also an example project I am working on here

/** @jsx html */
import { html } from 'snabbdom-jsx'
import ReactOnRails from 'snabbdom-on-rails'

const HelloMessage = ({name}) =>
  <div on-click={ _ => alert('Hi ' + name) }>
    {name}
  </div>;

const MyComponent = (props) => ( <HelloMessage {...props} /> )

ReactOnRails.register({ MyComponent })

This registered component can then be used in a rails view, like this, e.g. using haml:

= react_component('MyComponent', props: { name: 'Iseki' })

It will be nice if instead of ReactOnRails.register could use SnabbdomOnRails.register, this is a work in progress, at the moment this module just leaves alone all of the calls to register and render from the react_on_rails gem, but instead of rendering react components, renders snabbdom components. Happy to get some help from anyone who has some time and some more react_on_rails or snabbdom experience to help improve the current implementation.

Development

npm install
npm run build
npm test

License

MIT