Skip to content

Commit 83e2578

Browse files
committed
subject 11 converted to hooks
1 parent 3df1bd7 commit 83e2578

File tree

7 files changed

+302
-447
lines changed

7 files changed

+302
-447
lines changed

JavaScriptPrimer.md

Lines changed: 0 additions & 180 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $ npm start
1313

1414
Then, open a web browser to [http://localhost:8080](http://localhost:8080) where you'll see a list of subjects.
1515

16-
**IMPORTANT:** Please read the [JavaScript Primer](https://github.com/ReactTraining/react-workshop/blob/master/JavaScriptPrimer.md) before attending the workshop. It's a refresher on some of the newer bits of JavaScript you'll want to be familiar with in order to get the most out of the experience.
16+
**IMPORTANT:** Please read our [JavaScript Primer](https://reacttraining.com/blog/javascript-the-react-parts/) before attending the workshop. It's a refresher on some of the newer bits of JavaScript you'll want to be familiar with in order to get the most out of the experience.
1717

1818
### Troubleshooting
1919

subjects/11-Context/exercise.js

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,41 @@
1717
////////////////////////////////////////////////////////////////////////////////
1818
import React from "react";
1919
import ReactDOM from "react-dom";
20-
import PropTypes from "prop-types";
2120

22-
class Form extends React.Component {
23-
render() {
24-
return <div>{this.props.children}</div>;
25-
}
21+
function Form({ children }) {
22+
return <div>{children}</div>;
2623
}
2724

28-
class SubmitButton extends React.Component {
29-
render() {
30-
return <button>{this.props.children}</button>;
31-
}
25+
function SubmitButton({ children }) {
26+
return <button>{children}</button>;
3227
}
3328

34-
class TextInput extends React.Component {
35-
render() {
36-
return (
37-
<input
38-
type="text"
39-
name={this.props.name}
40-
placeholder={this.props.placeholder}
41-
/>
42-
);
43-
}
29+
function TextInput({ name, placeholder }) {
30+
return <input type="text" name={name} placeholder={placeholder} />;
4431
}
4532

46-
class App extends React.Component {
47-
handleSubmit = () => {
33+
function App() {
34+
function handleSubmit() {
4835
alert("YOU WIN!");
49-
};
36+
}
5037

51-
render() {
52-
return (
53-
<div>
54-
<h1>
55-
This isn't even my final <code>&lt;Form/&gt;</code>!
56-
</h1>
38+
return (
39+
<div>
40+
<h1>
41+
This isn't even my final <code>&lt;Form/&gt;</code>!
42+
</h1>
5743

58-
<Form onSubmit={this.handleSubmit}>
59-
<p>
60-
<TextInput name="firstName" placeholder="First Name" />{" "}
61-
<TextInput name="lastName" placeholder="Last Name" />
62-
</p>
63-
<p>
64-
<SubmitButton>Submit</SubmitButton>
65-
</p>
66-
</Form>
67-
</div>
68-
);
69-
}
44+
<Form onSubmit={handleSubmit}>
45+
<p>
46+
<TextInput name="firstName" placeholder="First Name" />{" "}
47+
<TextInput name="lastName" placeholder="Last Name" />
48+
</p>
49+
<p>
50+
<SubmitButton>Submit</SubmitButton>
51+
</p>
52+
</Form>
53+
</div>
54+
);
7055
}
7156

7257
ReactDOM.render(<App />, document.getElementById("app"));

0 commit comments

Comments
 (0)