Skip to content

Commit

Permalink
Remove Context calling React.Component constructor (#612)
Browse files Browse the repository at this point in the history
* Remove Context calling React.Component constructor

The React.Component takes one param in a call to super in the
constructor.

* remove unnecessary div
* Add railsContext to app for basic gen
  • Loading branch information
justin808 authored Nov 20, 2016
1 parent 1918345 commit 5ada94d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]

## [Unreleased]

## [6.2.1] - 2016-11-19
- Removed unnecesary passing of context in the HelloWorld Container example and basic generator. [#612](https://github.com/shakacode/react_on_rails/pull/612) by [justin808](https://github.com/justin808)

## [6.2.0] - 2016-11-19
##### Changed
- Updated the generator templates to reflect current best practices, especially for the redux version. [#584](https://github.com/shakacode/react_on_rails/pull/584) by [nostophilia](https://github.com/nostophilia).
Expand Down Expand Up @@ -378,7 +381,8 @@ Best done with Object destructing:
##### Fixed
- Fix several generator related issues.

[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.2.0...master
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.2.1...master
[6.2.1]: https://github.com/shakacode/react_on_rails/compare/6.2.0...6.2.1
[6.2.0]: https://github.com/shakacode/react_on_rails/compare/6.1.2...6.2.0
[6.1.2]: https://github.com/shakacode/react_on_rails/compare/6.1.1...6.1.2
[6.1.1]: https://github.com/shakacode/react_on_rails/compare/6.1.0...6.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export default class HelloWorldContainer extends React.Component {
name: PropTypes.string.isRequired, // this is passed from the Rails view
};

constructor(props, context) {
super(props, context);
constructor(props) {
super(props);

// How to set initial state in ES6 class syntax
// https://facebook.github.io/react/docs/reusable-components.html#es6-classes
Expand All @@ -19,9 +19,7 @@ export default class HelloWorldContainer extends React.Component {

render() {
return (
<div>
<HelloWorld name={this.state.name} updateName={this.updateName} />
</div>
<HelloWorld name={this.state.name} updateName={this.updateName} />
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ReactOnRails from 'react-on-rails';

import HelloWorldContainer from '../containers/HelloWorldContainer';

const HelloWorldApp = (props) => (
// _railsContext is the Rails context, providing contextual information for rendering
const HelloWorldApp = (props, _railsContext) => (
<HelloWorldContainer {...props} />
);

Expand Down
2 changes: 1 addition & 1 deletion lib/react_on_rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
module ReactOnRails
VERSION = "6.2.0".freeze
VERSION = "6.2.1.rc.3".freeze
end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-on-rails",
"version": "6.2.0",
"version": "6.2.1-rc.3",
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",
"main": "node_package/lib/ReactOnRails.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../..
specs:
react_on_rails (6.2.0)
react_on_rails (6.2.1.rc.3)
addressable
connection_pool
execjs (~> 2.5)
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/client/app/components/HelloWorld.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class HelloWorld extends React.Component {
};

// Not necessary if we only call super, but we'll need to initialize state, etc.
constructor(props, context) {
super(props, context);
constructor(props) {
super(props);
this.state = props.helloWorldData;
this.setNameDomRef = this.setNameDomRef.bind(this);
this.handleChange = this.handleChange.bind(this);
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/client/app/components/HelloWorldRedux.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default class HelloWorldRedux extends React.Component {
};

// Not necessary if we only call super, but we'll need to initialize state, etc.
constructor(props, context) {
super(props, context);
constructor(props) {
super(props);
this.setNameDomRef = this.setNameDomRef.bind(this);
this.handleChange = this.handleChange.bind(this);
}
Expand Down

0 comments on commit 5ada94d

Please sign in to comment.