Skip to content

Commit

Permalink
Merge pull request #839 from BookOfGreg/fix-#832
Browse files Browse the repository at this point in the history
Fallback to Render if Hydrate is not defined
  • Loading branch information
BookOfGreg authored Nov 13, 2017
2 parents 6a54c42 + a913f6b commit cac3e15
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
8 changes: 2 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# react-rails

#### Breaking Changes

#### New Features

#### Deprecation

## 2.4.2
#### Bug Fixes
- ReactDOM.hydrate() may not be defined for everyone, it will now use hydrate if it is defined or fallback to render #832

## 2.4.1

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ It outputs an ironically webpacked couple of files into `lib/assets/react-source
##### Updating ReactRailsUJS
- Update the UJS with `rake ujs:update`
- (For Maintainers) To release a new NPM version:
- Update the version in `react_ujs/package.json`
- Update the version in `package.json`
- Commit & push to master
- `bundle exec rake ujs:publish` (runs `npm publish`)

Expand Down
6 changes: 5 additions & 1 deletion lib/assets/javascripts/react_ujs.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ var ReactRailsUJS = {
}
throw new Error(message + ". Make sure your component is available to render.")
} else {
ReactDOM.hydrate(React.createElement(constructor, props), node);
if (typeof ReactDOM.hydrate === "function") {
ReactDOM.hydrate(React.createElement(constructor, props), node);
} else {
ReactDOM.render(React.createElement(constructor, props), node);
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react_ujs",
"version": "2.4.1",
"version": "2.4.2",
"description": "Rails UJS for the react-rails gem",
"main": "react_ujs/index.js",
"files": [
Expand Down
6 changes: 5 additions & 1 deletion react_ujs/dist/react_ujs.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ var ReactRailsUJS = {
}
throw new Error(message + ". Make sure your component is available to render.")
} else {
ReactDOM.hydrate(React.createElement(constructor, props), node);
if (typeof ReactDOM.hydrate === "function") {
ReactDOM.hydrate(React.createElement(constructor, props), node);
} else {
ReactDOM.render(React.createElement(constructor, props), node);
}
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion react_ujs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ var ReactRailsUJS = {
}
throw new Error(message + ". Make sure your component is available to render.")
} else {
ReactDOM.hydrate(React.createElement(constructor, props), node);
if (typeof ReactDOM.hydrate === "function") {
ReactDOM.hydrate(React.createElement(constructor, props), node);
} else {
ReactDOM.render(React.createElement(constructor, props), node);
}
}
}
},
Expand Down

0 comments on commit cac3e15

Please sign in to comment.