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
| const hoc = Wrapped => | |
| class extends React.Component { | |
| render() { | |
| // pass props from parent to the wrapped component | |
| return <Wrapped {...this.props} /> | |
| } | |
| } | |
| // usage: | |
| const WrappedComponent = hoc(SomeComponent) |
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
| let registration = { | |
| // ommitted for brevity | |
| setUsername: (r, e) => { | |
| let value = e.target.value | |
| value = value.replace("-", "") | |
| r.username = value | |
| } | |
| } |
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
| componentWillMount() { | |
| let proxy = {} | |
| for (var i in this.state) { | |
| if (typeof this.state[i] === "function") { | |
| this.foos[i] = state[i].bind(null, proxy) | |
| } else { | |
| let key = i | |
| Object.defineProperty(proxy, key, { | |
| set: value => this.setState({ [key]: value }), |
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
| let registration = { | |
| username: "username", | |
| password: "password", | |
| isRegistering: false, | |
| onRegister: r => { | |
| r.isRegistering = true | |
| setTimeout(() => { | |
| r.isRegistering = false | |
| }, 2000) |
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
| export const wrap = (state, WrappedComponent) => | |
| class extends React.Component { | |
| foos = {} | |
| state = state || {} | |
| set = e => { | |
| this.setState({ [e.target.name]: e.target.value }) | |
| }; | |
| componentWillMount() { |
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
| let registration = { | |
| username: "", | |
| password: "", | |
| isRegistering: false, | |
| onRegister: r => { | |
| // login(r.username, r.password).then()... | |
| r.setState({ isRegistering: true }) | |
| setTimeout(() => { | |
| r.setState({ isRegistering: false }) |
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
| const RegisterForm = ({ | |
| username, password, isRegistering, | |
| onRegister, set | |
| }) => ( | |
| <div> | |
| <h1>Register</h1> | |
| <div> | |
| <label>Username</label> | |
| <input type="text" name="username" value={username} onChange={set} | |
| /> |
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
| <div> | |
| <h1>Register</h1> | |
| <div> | |
| <label>Username</label> | |
| <input type="text" name="username" /> | |
| </div> | |
| <div> | |
| <label>Password</label> | |
| <input type="password" name="password" /> | |
| </div> |
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
| <ResourceDictionary | |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | |
| <Style x:Key="FloatingHeaderTextBoxStyle" TargetType="TextBox"> | |
| <Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}"/> | |
| <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}"/> | |
| <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/> | |
| <Setter Property="Background" Value="{ThemeResource SystemControlBackgroundAltHighBrush}"/> | |
| <Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundChromeDisabledLowBrush}"/> |
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
| using System; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| namespace Common | |
| { | |
| public interface ISet<T> : ICollection<T>, IEnumerable<T>, IEnumerable | |
| { | |
| bool Add(T item); |
NewerOlder