This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
import React from 'react'; | |
import debounce from 'utils/debounce'; | |
class EmailInput extends React.Component { | |
checkEmail = value => { | |
// only check if the field passes Yup email validation first | |
if ( | |
!this.props.form.errors[this.props.name].includes( | |
'invalid' /* or whatever your error message is*/ | |
) |
<!DOCTYPE html> | |
<html prefix="og: http://ogp.me/ns#"> | |
<head> | |
<!-- content-type, which overrides http equivalent header. Because of charset, this meta should be set at first. --> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<!-- Overrides http equivalent header. This tells IE to use the most updated engine. --> | |
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> | |
<!-- Tells crawlers how to crawl this page, and the role of this page. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta --> | |
<meta name="robots" content="index, follow"> |
function increment(props, state) { | |
return { | |
value: state.value + props.step, | |
}; | |
} | |
function decrement(props, state) { | |
return { | |
value: state.value - props.step, | |
}; |
// getComponent is a function that returns a promise for a component | |
// It will not be called until the first mount | |
function asyncComponent(getComponent) { | |
return class AsyncComponent extends React.Component { | |
static Component = null; | |
state = { Component: AsyncComponent.Component }; | |
componentWillMount() { | |
if (!this.state.Component) { | |
getComponent().then(Component => { |
class Nav extends React.Component { | |
constructor() { | |
super(); | |
this.onNav = this.onNav.bind(this); | |
} | |
onNav(idx) { | |
// do something with `this` and `idx` | |
} | |
render() { | |
return ( |
import { createStore, applyMiddleware, compose } from 'redux'; | |
// import { persistState } from 'redux-devtools'; | |
import rootReducer from '../reducers'; | |
import DevTools from '../containers/DevTools'; | |
export default function configureStore(initialState) { | |
const finalCreateStore = compose( | |
DevTools.instrument(), | |
// persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)) | |
)(createStore); |
This is a proposal for a lightning talk at the Reactive 2015 conference.
NOTE: If you like this, star ⭐ the Gist - the amount of stars decides whether it makes the cut!
React just got stateless components, meaning that they are in essence pure functions for rendering. Pure functions make it dead simple - even fun - to refactor your views
import React from 'react'; | |
/** | |
* Counter.js | |
* | |
* exposes: | |
* init | |
* update | |
* view | |
*/ |