Created
January 16, 2019 12:26
-
-
Save victorpavlenko/6f5862cf430fa342d18594d8af4d1ae5 to your computer and use it in GitHub Desktop.
Замыкание в functional component
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
Замыкание в functional component | |
function CustomForm ({handleSubmit}) { | |
let inputElement | |
return ( | |
<form onSubmit={() => handleSubmit(inputElement.value)}> | |
<input | |
type='text' | |
ref={(input) => inputElement = input} /> | |
<button type='submit'>Submit</button> | |
</form> | |
) | |
} |
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
<Twitter username='tylermcginnis33'> | |
{(user) => user === null | |
? <Loading /> | |
: <Badge info={user} />} | |
</Twitter> | |
import React, { Component, PropTypes } from 'react' | |
import fetchUser from 'twitter' | |
// fetchUser принимает имя пользователя и возвращает promise | |
// который резолвится с данными пользователя | |
class Twitter extends Component { | |
// закончите код здесь | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment