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

eh-rwr

v0.9.4-rc.1

Published

Js part of react_webpack_rails - webpack based React & Rails integration.

Downloads

4,755

Readme

ReactWebpackRails

Travis CI

!! DEPRECATED !!

Consider using Webpacker instead.

If you are looking for view helpers and/or redux integrations, see:

  1. react-rails (currently using webpacker)
  2. react-on-rails (migration to webpacker in progress, using forked version now)

Rails - Webpack setup with React integration.

This gem provides easy and convenient way to build modern JavaScript stack on top of Rails applications using Webpack and React.

Features

Plugins:

  • rwr-alt plugin that makes it possible to populate and share Alt stores between react component located in different parts of rails views.
  • rwr-redux allows to use redux state containers in a rails views.
  • rwr-react_router react-router integration.
  • rwr-view_helpers handy view helpers.

Installation

Add this line to your application's Gemfile:

gem 'react_webpack_rails'

Execute:

$ bundle

Then run installation:

$ rails g react_webpack_rails:install

read more about install generator

Babel

By default, react-webpack-rails uses Babel Stage 1 - Proposal. If you want to change the stage, you can do so in the .babelrc file. It is however not recommended to use Stage 0 in a production app, because the features present there can be dropped, which would break your application.

Usage

Check docs for detailed api description.

to use hot-reloading add partial in your application.html.erb to <body>:

(it's not needed when you want to use just webpack in watch mode without hot-reloading)

<%= render 'layouts/react_hot_assets' %>

Register component in index.js

import Component from './components/some-component';
RWR.registerComponent('customComponentName', Component);

Use it in rails view

<%= react_component('customComponentName', { user: User.last }) %>

Use it in javascript file

const element = $('#my-element');
RWR.renderComponent('customComponentName', {user_id: 1}, element);

Render component in controller

def action_name
  render react_component: 'customComponentName', props: { user_id: 1 }
end

Development environment

Run webpack in watch mode using script:

$ npm start

Run webpack in hot-auto-reloading mode using script (to use it you have to add react_hot_assets partial as mentioned before):

$ npm run start-hot-dev

If you are using server side render in components (it's enabled by default in generated example), run node server:

$ npm run rwr-node-dev-server

Production environment

Run webpack in production mode before compiling assets using script:

$ npm run build

If you are using server side render (it's enabled by default in generated example), run node server:

$ npm run rwr-node-server

Deployment

Check docs/deployment.md

Contributing

See the contribution guide.

License

The gem is available as open source under the terms of the MIT License.