Skip to content

Instantly share code, notes, and snippets.

@quisido
Created October 31, 2018 17:24
Show Gist options
  • Save quisido/479e2a2e0f35c0cfceda5512f1d12f06 to your computer and use it in GitHub Desktop.
Save quisido/479e2a2e0f35c0cfceda5512f1d12f06 to your computer and use it in GitHub Desktop.
Replacing Redux with ReactN to reduce complexity and bundle size
import React, { Component } from 'reactn';
import './App.css';
class App extends Component {
componentDidMount() {
this.setGlobal(
fetch('index.html')
.then(response => response.text())
.then(html => ({
data: html
}))
);
}
incrementX = () => {
this.setGlobal(state => ({
x: state.x + 1
}));
};
render() {
return (
<button
children={this.global.x}
onClick={this.incrementX}
/>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment