Skip to content

Instantly share code, notes, and snippets.

@ramubotsplash
Created May 1, 2018 16:26
Show Gist options
  • Save ramubotsplash/1b7a1b02608d385b6c162330b7286427 to your computer and use it in GitHub Desktop.
Save ramubotsplash/1b7a1b02608d385b6c162330b7286427 to your computer and use it in GitHub Desktop.
Converting ReactJs to Pure Javascript Class structure
// FROM: ReactJs
export default class HostApp extends Component {
constructor(props: HostAppProps) {
super(props);
...
}
componentDidMount() {
...
}
...
render() {
return (
<div>
...
</div>
);
}
}
// TO: Js
export default class HostApp {
constructor(rootEl: Object, props: HostAppProps) {
super(props);
...
this.rootEl = rootEl;
this.props = props;
}
componentDidMount() {
...
}
...
getBubbleElement() {
const { settings } = this.props;
...
const el = document.createElement('div');
el.setAttribute('id', CHAT_BUBBlE_ID);
...
}
render() {
const bubbleEl = this.getBubbleElement();
this.rootEl.appendChild(chatEl);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment