Created
October 31, 2018 17:24
-
-
Save quisido/479e2a2e0f35c0cfceda5512f1d12f06 to your computer and use it in GitHub Desktop.
Replacing Redux with ReactN to reduce complexity and bundle size
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
| 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