@cloudcannon/react-connector
Advanced tools
Comparing version 1.0.2 to 1.0.3
54
index.js
@@ -1,35 +0,37 @@ | ||
import React from 'react'; | ||
const React = require('react'); | ||
export default function CloudCannonConnect(Component) { | ||
return class LivePageComponent extends React.Component{ | ||
constructor(props) { | ||
super(props); | ||
this.state = {} | ||
} | ||
componentDidMount() { | ||
window.CloudCannon = { | ||
trigger: (eventName, frontMatter) => { | ||
this.setState(frontMatter); | ||
module.exports = { | ||
CloudCannonConnect: function (Component) { | ||
return class LivePageComponent extends React.Component{ | ||
constructor(props) { | ||
super(props); | ||
this.state = {} | ||
} | ||
componentDidMount() { | ||
window.CloudCannon = { | ||
trigger: (eventName, frontMatter) => { | ||
this.setState(frontMatter); | ||
} | ||
}; | ||
} | ||
componentWillUnmount() { | ||
if (window.CloudCannon) { | ||
window.CloudCannon.trigger = null; | ||
} | ||
}; | ||
} | ||
componentWillUnmount() { | ||
if (window.CloudCannon) { | ||
window.CloudCannon.trigger = null; | ||
} | ||
} | ||
render() { | ||
const hydratedProps = { | ||
...this.props, | ||
page: { | ||
...this.props.page, | ||
...this.state, | ||
render() { | ||
const hydratedProps = { | ||
...this.props, | ||
page: { | ||
...this.props.page, | ||
...this.state, | ||
} | ||
} | ||
return React.createElement(Component, hydratedProps, null); | ||
} | ||
return React.createElement(Component, hydratedProps, null); | ||
} | ||
} | ||
} |
{ | ||
"name": "@cloudcannon/react-connector", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A React connector for activating live visual editing in CloudCannon", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
@@ -8,0 +7,0 @@ "test": "echo \"Error: no test specified\" && exit 1" |
2056
32
No