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 User = ({ name, friends }) => ( | |
<div> | |
Name: {name} | |
{friends && friends.map(friend => <User key={friend.name} {...friend} />)} | |
</div> | |
); | |
User.propTypes = { | |
name: PropTypes.string.isRequired, | |
friends: PropTypes.arrayOf( |
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 User = ({ name, friends }) => ( | |
<div> | |
Name: {name} | |
{friends.map(friend => ( | |
<User key={friend.name} {...friend} /> | |
))} | |
</div> | |
); |
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 FirstNameField from './FirstNameField'; | |
import LastNameField from './LastNameField'; | |
class SimpleForm extends React.Component { | |
... | |
render() { | |
const { firstNameError, firstName, lastName, lastNameError } = 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 from 'react'; | |
import TextField from './TextField'; | |
const FirstNameField = ({...rest}) => ( | |
<TextField name="firstName" | |
label="First name:" | |
{...rest} /> | |
); | |
export default FirstNameField; |
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 from 'react'; | |
import TextField from './TextField'; | |
const LastNameField = ({...rest}) => ( | |
<TextField name="lastName" | |
label="Last name:" | |
{...rest} /> | |
); | |
export default LastNameField; |
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 TextField from './TextField'; | |
class SimpleForm extends React.Component { | |
... | |
render() { | |
const { firstNameError, firstName, lastName, lastNameError } = 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 from 'react' | |
import style from "./style"; | |
const TextField = ({name, onChange, onBlur, error, label}) => ( | |
<div style={style.inputGroup}> | |
<label> | |
{label} | |
<input | |
style={style.input} | |
type="text" |
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
class SimpleForm extends React.Component { | |
state = { | |
... | |
lastName: "", | |
lastNameError: "" | |
}; | |
validateName = ...; | |
onFirstNameBlur = ...; |
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 from "react"; | |
const Greetings = ({ firstName, lastName }) => ( | |
<div> | |
Hey you! {firstName} {lastName}! | |
</div> | |
); | |
export default Greetings; |
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 style from './style'; | |
class SimpleForm extends React.Component { | |
... | |
render() { | |
const { firstNameError, firstName, lastName } = this.state; | |
return ( | |
<div style={style.form}> |
NewerOlder