Skip to content

Instantly share code, notes, and snippets.

@hwclass
Created November 30, 2017 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwclass/e35e31b0176c7400cf72541506577480 to your computer and use it in GitHub Desktop.
Save hwclass/e35e31b0176c7400cf72541506577480 to your computer and use it in GitHub Desktop.
Q: How many ways are there to make an AJAX call in Javascipt?
const url = 'http...'
const response = await fetch(url).then(response => response.toJSON())
.then(response => response.data)
Q: How can we write a method like the following:
sum(2)(4)
// returns 6
A:
const makeSum = initialSum => value => initialSum + value
const makeSum = function(initialSum) {
return function (value) {
return initialSum + value
}
}
Q: Stateless functional components
import Some from './components/Some'
const App = () => <div><Some /></div>
A:
// Some renders some string
const App = () => <div><Text content='Some name'>Some name</Text></div>
const Text = ({name, children}) => <h1>{children}</h1>
// v < 16
render() {
return(
<div>
<Text />
</div>
)
}
// v = 16
render() {
return(
[
<Text />
<Text />
]
)
}
Q:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment