Giter Club home page Giter Club logo

Comments (9)

amanolar94 avatar amanolar94 commented on June 9, 2024 1

@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.

rwieruch avatar rwieruch commented on June 9, 2024

Thanks for reporting @amanolar94 I or maybe someone else will check it! :)

from the-road-to-learn-react.

rwieruch avatar rwieruch commented on June 9, 2024

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.

amanolar94 avatar amanolar94 commented on June 9, 2024

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.

rwieruch avatar rwieruch commented on June 9, 2024

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.

amanolar94 avatar amanolar94 commented on June 9, 2024

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.

lex111 avatar lex111 commented on June 9, 2024

@rwieruch can it be closed?

from the-road-to-learn-react.

rwieruch avatar rwieruch commented on June 9, 2024

@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.

teemopower avatar teemopower commented on June 9, 2024

sd

from the-road-to-learn-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.