I hereby claim:
- I am tsnieman on github.
- I am tsnieman (https://keybase.io/tsnieman) on keybase.
- I have a public key ASA5SFROUnA_bZNbvS5XuDyOHY-LKIrLAfGDM8Hi5I8G9go
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| // 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 => { |
| // Custom webpack loader which simply removes any use of 'composes'. | |
| // This is because this bug https://github.com/istarkov/babel-plugin-webpack-loaders/issues/97 | |
| // causing issues with testing. | |
| module.exports = function removeComposes(source) { | |
| if (process.env.NODE_ENV === 'test') { | |
| const hasComposes = source.indexOf('composes') > 0; | |
| if (!hasComposes) return source; | |
| var numOfOccurences = source.match(/composes/g).length; |
Common problem...
<SomeComponent propVariable={propVariable} />I repeat "propVariable". I find myself doing this a lot... like, several times for one JSX object (usually a React component) is not uncommon.
Proposed solution...
<SomeComponent [propVariable] />| const address = 'Space Needle, 400 Broad St, Seattle, WA 98109'; | |
| const globalAddressSymbol = Symbol.for(address); // Search global Symbol registry for existing & return it, otherwise create it in the global registry. | |
| const uniqueAddressSymbol = Symbol(address); // Creates Symbol(uniqueAddressSymbol), a guaranteed unique key. | |
| console.log(globalAddressSymbol !== uniqueAddressSymbol); // Symbols created outside of the global registry are ALWAYS unique. | |
| console.log(globalAddressSymbol === Symbol.for(address)); // because `Symbol.for` accesses the global Symbol registry | |
| const addressesIndex = { | |
| [globalAddressSymbol]: { // Address can be used as a key via Symbol (i.e. for normalization) | |
| 'prettyAddress': address, | |
| 'latLng': [47.6204, -122.3491], | |
| }, |
| // Basics | |
| import { Component, PropTypes } from 'react'; | |
| import { connect } from 'react-redux'; | |
| import actions from 'actions/index'; | |
| class Auth extends Component { | |
| constructor(props) { | |
| super(props); | |
| } |
| class ParentComponent extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| // Default state can be defined here. | |
| post: { | |
| title: '', | |
| content: '', | |
| author: '', |
Now that he's in the national spotlight he's getting a lot of unwarranted hate. There's a rush to discredit him, as if he either doesn't have technical details for his plans (he does) or that he doesn't know how to pay for his proposals (he does). Sanders' campaign is based on the same principle his whole career has been; ethics in politics. The difference between him and most other leftist politicians is that he has the record to back up his rhetoric; he's shown consistency in both message and accuracy for decades.
Here are some old C-Span videos of Bernie ranting about things in Congress -- you might notice how often he's on point long before most of America catches up.
| // In the parent component ... | |
| render() { | |
| let myOnSuccessFunction = function({word, color}) { | |
| alert('word: ', word) | |
| alert('color: ', color) | |
| } | |
| return ( | |
| <ColorWordForm | |
| onSave={myOnSuccessFunction} |
| // This is a stateless functional component which | |
| // largely acts like a 'normal' Class-based component's | |
| // `render()` function. | |
| var Hello = function(props) { | |
| return <div>Hello, {props.name}</div>; | |
| } | |
| // Shorthand. | |
| var Hello = props => <div>Hello, {props.name}</div>; |