This file contains 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 [storeData, setStoreData] = useStoreQuery(); | |
setStoreData((prev) => ({ ...prev, user: 'jane', country: 'US' })); | |
*/ | |
const useStoreQuery = () => { | |
const queryKey = ["storeQuery"]; | |
const initialData: InitialStoreData = { | |
bookDetails: {}, | |
}; |
This file contains 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 {useRef} from 'react'; | |
import validators from './validators'; | |
/* Usage | |
const [user, setUser] = useState({ | |
username: '', | |
password: '', | |
}); |
This file contains 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
/** | |
* Remove duplicate values from an array | |
* @param {[] | Object[]} obj - array of values or array of objects | |
* @param {string} [prop] prop - the property in the objects which will be used as a unique value | |
* @returns {[]} | |
*/ | |
export const removeDuplicatesFromArray = (obj, prop) => { | |
return Object.values(obj.reduce((acc, cur) => { | |
return { | |
...acc, |
This file contains 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
/* Example | |
const q = EventQueue({}); You can also use the 'new' keyword | |
q.enQueue(async () => { | |
// [CODE HERE] | |
}); | |
OR |
This file contains 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 default { | |
name: "match-media", | |
props: { | |
mediaWidth: { | |
type: Array, | |
required: true | |
} | |
}, | |
data() { | |
return { |
This file contains 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
/* | |
## Example ## | |
<MatchMedia mediaWidth={["(min-width: 768px)", "(min-width: 1280px)"]}> | |
<Checkbox | |
id="check_1" | |
label="Hello World!" | |
checked={isChecked} | |
onChange={() => this.setState({ isChecked: !isChecked })} |
This file contains 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 'react'; | |
import PropTypes from 'prop-types'; | |
export default class Redraw extends Component { | |
constructor(props) { | |
super(props); | |
this.infoMessages = { | |
warning: 'You cannot use Redraw to return an array of children in v.15.x.x', | |
}; |
This file contains 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, PropTypes} from 'react'; | |
export const EnhanceDecorator = (options) => (TargetComponent) => { | |
class EnhanceComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {}; | |
} |
This file contains 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, PropTypes} from 'react'; | |
import Animate from 'grommet/components/Animate'; | |
export const RouteTransition = (options = {"animation": "fade", "duration": 1000, "delay": 0}) => (TargetComponent) => { | |
class EnhanceComponent extends Component { | |
constructor(props) { | |
super(props); | |
} | |
render() { |