Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Ken Stone
29,703 Pointsprops vs. state for login component
If I have a Login component that has two inputs email and password. Currently it is a class with props.
I think I should remove the isLoggedIn and raise that state up and have a separate LogOut component.
In that case does this Login Component need props? Can it be switched to a function and only use state? Essentially just passing the email and password up.
class Login extends Component {
constructor(props) {
super(props);
this.handleEmail = this.handleEmail.bind(this);
this.handlePassword = this.handlePassword.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleClear = this.handleClear.bind(this);
this.handleLogout = this.handleLogout.bind(this);
this.state = {
email: '',
password: '',
isLoggedIn: false
}
}