Comments (4)
Can you copy and paste your code for onSearchSubmit? It seems to work fine for me, and I've been following the version of the PDF I downloaded on December 18th.
from the-road-to-learn-react.
As a reference https://github.com/rwieruch/hackernews-client that might help.
from the-road-to-learn-react.
Will close this now, because we didn't hear anything back.
from the-road-to-learn-react.
I see this error on:
- Firefox Developer Edition 67.0b16 (64-bit)
- Microsoft Edge 44.17763.1.0
- Chrome Version 74.0.3729.131 (Official Build) (64-bit)
with versions running on Ubuntu18.04 WSL:
- nodejs version v8.10.0
- npm version 3.5.2
- react version 16.8.5-canary-297165f1e
The physical book I'm using has its last changelog as 10. January 2017, but this section in chapter 3 appears unchanged (hard to diff w/ a piece of paper)
The code previously requested is below, and I have tried it without the anon function as well.
onSearchSubmit = (event) => {
const {searchTerm} = this.state
this.fetchSearchTopStories(searchTerm);
event.preventDefault();
}
[EDIT]: The issue arose when the guide requested us to modify onSearchSubmit to take an argument (event) which led to 'the most common bug' for react developers.
The render()
function in our component must be an anonymous function now that it takes a variable.
i.e. now onSubmit={}
requires more than a function definition, it needs to be encapsulated in an anonymous function lest it only execute at runtime.
<Search value={searchTerm}
onChange={this.onSearchChange}
onSubmit={(event) => {this.onSearchSubmit(event)}}>search</Search>
It would be beneficial to remind new programmers at this stage to change this code, as the previous page in the physical book instructs them to rewrite onSearchSubmit
in the render()
function away from proper usage:
<Search value={searchTerm}
onChange={this.onSearchChange}
onSubmit={this.onSearchSubmit}>search</Search> // This won't fly, but the book says to write it.
from the-road-to-learn-react.
Related Issues (20)
- Translate to Spanish
- Typos HOT 3
- Verify and Fix: Functioning Binding Example HOT 1
- Translate to Vietnamese HOT 1
- Link Shortener HOT 1
- Index Page
- UX/A11Y: Improve Label
- A11Y: use button outline
- Source Code: Show after every Section rather than only every Chapter HOT 1
- Source Code Project: Folder/Folder Refactoring
- Source Code Project: Import/Export Statement
- Table component test failing in "Snapshot Tests with Jest" section HOT 1
- Hot Module replacement is not working ! Chapter 1 HOT 1
- Link redirection is no longer correct. HOT 1
- access a state object
- Translate to Thai HOT 1
- refs in stateless components HOT 1
- Would you mind to change the `bit.ly links` to direct links ? HOT 2
- Wikipedia MVC link in chapter1.md (line 9) shows รขโฌโ instead of dash (PDF version). Link broken.
- Translate to Persian
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from the-road-to-learn-react.