@@ -163,6 +163,50 @@ export const App = () => {
163163};
164164```
165165
166+ - Now let's jump into _ NameEditComponent_ and update the contract and
167+ implementation:
168+
169+ ``` diff
170+ interface Props {
171+ initialUserName: string;
172+ + editingName: string;
173+ - onNameUpdated: (newName: string) => any;
174+ + onNameUpdated: () => any;
175+ + onEditingNameUpdated: (newEditingName: string) => any;
176+ }
177+ ```
178+
179+ ``` diff
180+ export const NameEditComponent = (props: Props) => {
181+ - const [editingName, setEditingName] = React.useState(props.initialUserName);
182+
183+ const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
184+ - setEditingName(e.target.value);
185+ + props.onEditingNameUpdated(e.target.value);
186+ };
187+
188+ const onNameSubmit = (event: any): any => {
189+ - props.onNameUpdated(editingName);
190+ + props.onNameUpdated();
191+ };
192+
193+ - if(props.initialUserName !== lastInitialName) {
194+ - setLastInitialName(props.initialUserName);
195+ - setEditingName(props.initialUserName);
196+ - }
197+
198+
199+ return (
200+ <>
201+ <label>Update name:</label>
202+ - <input value={editingName} onChange={onChange} />
203+ + <input value={props.editingName} onChange={onChange} />
204+ <button onClick={onNameSubmit}>Change</button>
205+ </>
206+ );
207+ };
208+ ```
209+
166210# About Basefactor + Lemoncode
167211
168212We are an innovating team of Javascript experts, passionate about turning your ideas into robust products.
@@ -172,4 +216,3 @@ We are an innovating team of Javascript experts, passionate about turning your i
172216[ Lemoncode] ( http://lemoncode.net/services/en/#en-home ) provides training services.
173217
174218For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend
175-
0 commit comments