Created
May 1, 2018 16:26
-
-
Save ramubotsplash/1b7a1b02608d385b6c162330b7286427 to your computer and use it in GitHub Desktop.
Converting ReactJs to Pure Javascript Class structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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