Skip to content

Commit

Permalink
Merge pull request #14 from mmarkelov/Rewrite-VK-API
Browse files Browse the repository at this point in the history
Fix VK component crash
  • Loading branch information
mmarkelov committed Feb 13, 2019
2 parents ef4d572 + fbe97ac commit b138325
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-vk-examples",
"version": "4.0.1",
"version": "4.1.1",
"description": "VK API bindings for React",
"scripts": {
"dev": "webpack-dev-server --mode development",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-vk",
"private": false,
"version": "4.0.2",
"version": "4.1.1",
"main": "dist/react-vk.cjs.js",
"module": "dist/react-vk.esm.js",
"browser": "dist/react-vk.umd.production.min.js",
Expand Down
7 changes: 6 additions & 1 deletion src/VK.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ export default class VK extends React.Component {
state = { vk: null };

componentDidMount() {
const { onApiAvailable } = this.props;
const { onApiAvailable, apiId } = this.props;
if (
typeof window !== "undefined" &&
window.document &&
window.document.createElement
) {
this.VKinit().then(vk => {
onApiAvailable(vk);
if (apiId) {
vk.init({
apiId
});
}
if (this._mounted) this.setState({ vk });
});
}
Expand Down

0 comments on commit b138325

Please sign in to comment.