react-rails-ujs
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -20,3 +20,7 @@ 'use strict'; | ||
'NAME_ATTR': 'data-react-class', | ||
'PROPS_ATTR': 'data-react-props' | ||
'PROPS_ATTR': 'data-react-props', | ||
render: function render(component, props) { | ||
return _react2.default.createElement(component, props); | ||
}, | ||
strict: true | ||
}; | ||
@@ -42,7 +46,9 @@ | ||
} | ||
throw new Error('[react-rails-ujs] ' + message); | ||
if (config.strict) { | ||
throw new Error('[react-rails-ujs] ' + message); | ||
} | ||
} else { | ||
_reactDom2.default.render(_react2.default.createElement(component, props), node); | ||
_reactDom2.default.render(config.render(component, props), node); | ||
} | ||
} | ||
} |
{ | ||
"name": "react-rails-ujs", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "mounting components built with webpack (compatible with react-rails)", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -33,3 +33,3 @@ # react-rails-ujs | ||
import { mountComponents } from './react-rails-ujs'; | ||
import { mountComponents } from 'react-rails-ujs'; | ||
@@ -41,1 +41,36 @@ import { Message } from './components/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 }); |
@@ -7,2 +7,4 @@ import React from 'react'; | ||
'PROPS_ATTR': 'data-react-props', | ||
render: (component, props) => React.createElement(component, props), | ||
strict: true, | ||
}; | ||
@@ -26,7 +28,9 @@ | ||
} | ||
throw new Error(`[react-rails-ujs] ${message}`); | ||
if (config.strict) { | ||
throw new Error(`[react-rails-ujs] ${message}`); | ||
} | ||
} else { | ||
ReactDOM.render(React.createElement(component, props), node); | ||
ReactDOM.render(config.render(component, props), node); | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17253
8
70
75