Skip to content

Fallback to Render if Hydrate is not defined #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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