Created
June 9, 2017 08:16
-
-
Save isnifer/b9cfb588b2cab134d8d9107653424a81 to your computer and use it in GitHub Desktop.
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 loadSomething(a, b, nextPage = 1) { | |
console.log({ a, b, nextPage }) | |
} | |
function loadInventorySearch({ a, b, nextPage = 1 }) { | |
console.log({ a, b, nextPage }) | |
} | |
// Do not pass nextPage | |
loadSomething(10, 20) // a: 10, b: 20, nextPage: 1 | |
// Pass int as nextPage | |
loadSomething(10, 20, 30) // a: 10, b: 20, nextPage: 30 | |
// Pass undefined as nextPage | |
loadSomething(10, 20, undefined) // a: 10, b: 20, nextPage: 1 | |
// Pass null as nextPage | |
loadSomething(10, 20, null) // a: 10, b: 20, nextPage: null !!!!!!! | |
class SomeReactClass { | |
loadInventorySearch = (nextPage) => { | |
const { a, b } = this.props | |
const props = { b, a } | |
if (nextPage) { | |
props.page = nextPage | |
} | |
return loadInventorySearch(props) | |
} | |
loadSomething = (nextPage) => { | |
const { a, b } = this.props | |
if (nextPage) { | |
return loadSomething(a, b, nextPage) | |
} | |
return loadSomething(a, b) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment