Skip to content

Instantly share code, notes, and snippets.

View ramubotsplash's full-sized avatar

Ramu Pulipati ramubotsplash

View GitHub Profile
@ramubotsplash
ramubotsplash / ReactToJs-setState.jsx
Last active May 1, 2018 16:54
ReactJs to Pure Js with setState
// FROM: ReactJs
activateChat() {
this.setState({ isChatActive: true });
}
// TO: Js
setState = (updatedState: Object) => {
this.state = {...this.state, ...updatedState};
setTimeout(() => this.updateClasses());
}
@ramubotsplash
ramubotsplash / ReactToJs-ClassStructure.jsx
Created May 1, 2018 16:26
Converting ReactJs to Pure Javascript Class structure
// FROM: ReactJs
export default class HostApp extends Component {
constructor(props: HostAppProps) {
super(props);
...
}
componentDidMount() {
...
}
...
// FROM ReactJs
import React from 'react';
import ReactDOM from 'react-dom';
let rootEl = document.getElementById('botsplash-chat-root');
ReactDOM.render(
<HostApp
appId={appId}
serverUrl={serverUrl}
settings={settings}
function optional_arg(input, options, callback) {
if (!options) {
options = {};
} else if (typeof options === 'function') {
callback = options;
options = {};
}
//....
}