Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-rails-ujs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-rails-ujs

mounting components built with webpack (compatible with react-rails)

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-51.3%
Maintainers
1
Weekly downloads
 
Created
Source

react-rails-ujs

npm version Downloads

This npm package is replacement for react-rails when assets pipeline is completely disabled and replaced with webpack bundles.

Install

npm i --save react-rails-ujs

Add react_component helper

module ApplicationHelper
  def react_component(name, props = {}, options = {}, &block)
    html_options = options.reverse_merge(data: {
      react_class: name,
      react_props: (props.is_a?(String) ? props : props.to_json)
    })
    content_tag(:div, '', html_options, &block)
  end
end

Usage

Render components into rails views

<%= react_component('Message', text: 'Hello react-rails-ujs') %>

Mount webpack bundled components

import { mountComponents } from 'react-rails-ujs';

import { Message } from './components/Message';

mountComponents({
  Message,
});

Usage with React Hot Reload

import React from 'react';
import { AppContainer } from 'react-hot-loader';
import { mountComponents } from 'react-rails-ujs';

import { Message } from './components/Message';

const render = (component, props) => (
  <AppContainer><component {...props}/></AppContainer>
);

mountComponents({
  Message,
}, module.hot ? { render } : {});

Usage with Redux

import React from 'react';
import { Provider } from 'react-redux'
import { mountComponents } from 'react-rails-ujs';

import createStore from './store/createStore';
import { Message } from './components/Message';

const store = createStore();

const render = (component, props) => (
  <Provider store={store}><component {...props}/></Provider>
);

mountComponents({
  Message,
}, { render });

Keywords

FAQs

Package last updated on 27 Mar 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc