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
| function sortProperties(objToSort) { | |
| var properties = Object.keys(objToSort).sort(); | |
| var result = {}; | |
| properties.forEach(function (prop) { | |
| if (!objToSort[prop]) { | |
| result[prop] = objToSort[prop]; | |
| } | |
| else if (Array.isArray(objToSort[prop])){ | |
| result[prop] = objToSort[prop].map(sortProperties); | |
| } |
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
| function formatDate(date) { | |
| return (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear(); | |
| } | |
| $('form[name=accountDetailForm]').on('submit', function (e) { | |
| alert('Submitted!'); | |
| e.preventDefault(); | |
| }); | |
| $('#dateRange a[data-date-range]').click(function (e) { |
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 user = { | |
| teacherId: 1, | |
| first: 'Bob', | |
| last: 'Smith', | |
| room: { | |
| floor: 2, | |
| number: 40 | |
| } | |
| }; |
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
| $.Deferred = (function (baseDeferred) { | |
| var slicer = [].slice; | |
| var cond = function (truthy) { | |
| return this[truthy ? 'resolve' : 'reject'].apply(this, slicer.call(arguments, 1)); | |
| }; | |
| return function() { | |
| var dfd = baseDeferred.apply(this, arguments); | |
| dfd.cond = cond; |
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
| function translateWebkitPermission(code) { | |
| switch (code) { | |
| case 0: | |
| return 'granted'; | |
| case 1: | |
| return 'default'; | |
| case 2: | |
| return 'denied'; | |
| } | |
| } |
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 c = (function () { | |
| this.context = 'lexical context'; | |
| const bar1 = () => { | |
| console.log('bar 1:', this.context); | |
| }; | |
| const curry = (fn) => { | |
| console.log('bar 3 curryer context:', this.context); | |
| return () => { |
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
| class MyChildComponent extends Component { | |
| render() { | |
| return ( | |
| <View style={[{ height: 100 }, this.props.style]}> | |
| The height of this container will be **50** | |
| </View> | |
| ); | |
| } | |
| } |
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
| compose( | |
| ownState( | |
| set => ({ | |
| setValue: e => set(state => ({ | |
| ...state, | |
| value: e.target.value, | |
| })), | |
| clearValue: () => set(state => ({ | |
| ...state, | |
| 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
| const propMap = (mapper) => (WrappedComponent) => (props) => <WrappedComponent {...mapper(props) } /> | |
| const mapStateToProps = (state) => { | |
| user: state.currentUser | |
| } | |
| // This component will display the firstName of the current user | |
| const MyComponent = compose( | |
| connect(mapStateToProps), | |
| propMap(props => ({ |
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
| /* @flow */ | |
| import * as React from 'react' | |
| import type { ComponentType, ElementConfig } from 'react' | |
| declare type Action = { type: string } | |
| declare type Dispatch = (arg: Action | Array<Action>) => mixed | |
| declare type MapStateToProps<S, OP, SP> = (state: S, ownProps: OP) => SP | |
| declare type MapDispatchToProps<OP, DP> = (dispatch: Dispatch, ownProps: OP) => DP | |
| declare type MergeProps<SP, DP, OP, MP> = (stateProps: SP, dispatchProps: DP, ownProps: OP) => MP |
OlderNewer