-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq1.tsx
More file actions
32 lines (30 loc) · 961 Bytes
/
q1.tsx
File metadata and controls
32 lines (30 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as React from 'react';
class SignupForm extends React.Component {
constructor() {
super();
this.state = { email: ""}
this.handleSubmit =this.handleSubmit.bind (this)
}
handleSubmit(e){
e.preventDefault();
e.stopPropagation();
console.log(`Sending ${this.state.email}`);
}
// ... Code to submit form
render() {
return (
<form onSubmit={this.handleSubmit}>
<input type="text" value={this.state.email} />
<input type="submit" value="Submit" />
</form>
);
}
// You test this in a browser. You try to type in the text input field but nothing appears. What's wrong?
// Select the best option:
// A. e.preventDefault() is causing the keystrokes to not register
// B.
// The text input needs a readonly={false} attribute
// Time 1:52
// C. The component should be using props instead of state; Change all usages of this.state.email to this.props.email.
// D.
// The value of this.state.email never changes; The text input needs an onChange attribute