Comments (9)
@rwieruch Could it be that this happens because in the tests that we write we don't put an onClick function in the test components? In Table test for example we have some props defined but in Button test not.
EDIT:
I ultimately created a test function and used afterwards and it throws no warnings. What do you think?
describe('Button', () => {
const testFunction = () => true;
it('renders', () => {
const div = document.createElement('div');
ReactDOM.render(<Button onClick={testFunction}>Give Me More</Button>, div);
});
test('snapshots', () => {
const component = renderer.create(
<Button onClick={testFunction}>Give Me More</Button>
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
});`
from the-road-to-learn-react.
Thanks for reporting @amanolar94 I or maybe someone else will check it! :)
from the-road-to-learn-react.
Afterward it worked, right?
I think when using and keeping prop-types throughout the remaining chapters, there will be a couple of these warnings along the way of forgetting to define a prop. That's why the book mentions in the beginning of the prop-types chapter that all the changes are omitted for the remaining chapters. See #53 Would you think there is some explanation missing around this topic/issue in the book?
from the-road-to-learn-react.
Yes afterwards it worked fine, no warnings. Do you think this solution above is proper?
You are right #53 pretty muchs covers it :P .
I wouldn't say there is a problem. It's just that I've been struggling with this for some time and after I saw the fake props in the test code for Table component bellow I realised that I had to do something similar with the functions also.
I believe most people passed these warnings but if someone wants to get rid of them is mabe gonna have a hard time.
A suggestion would be to put the code for the Table component first so that the reader gets a hint about that or just mention that he has to do that or something similar in order to get rid of these warnings.
Thanks for your time anyway!
from the-road-to-learn-react.
Yes, I think it would be a good step to add the code to fix the first warning coming up after the PropTypes chapter. In your case, was it the first occasion that the warning happened? Then I would add it at this place.
from the-road-to-learn-react.
Well actually I created the PropTypes for Search component also as you suggested so this was the first occasion and the afterwards.
from the-road-to-learn-react.
@rwieruch can it be closed?
from the-road-to-learn-react.
@lex111 I would want to keep it open as "won't fix", because many people stumble upon this issue while reading the book and they wouldn't necessarily look into the closed issues.
from the-road-to-learn-react.
sd
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.