Skip to content

Update docs for stable Hooks #1629

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 27 commits into from
Feb 6, 2019
Merged

Update docs for stable Hooks #1629

merged 27 commits into from
Feb 6, 2019

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Feb 5, 2019

Fork of #1593 with release date modified.

@reactjs-bot
Copy link

Deploy preview for reactjs ready!

Built with commit 3091413

https://deploy-preview-1629--reactjs.netlify.com

@gaearon
Copy link
Member

gaearon commented Feb 5, 2019

Also need Sunil’s change into the log. “Add TestUtils.act() to match browser behavior in tests” or something.

@gaearon
Copy link
Member

gaearon commented Feb 5, 2019

(And changelog updates need to be reflected in React PR)

@bvaughn
Copy link
Contributor Author

bvaughn commented Feb 5, 2019

That's already in the blog post?

We have added a new API called ReactTestUtils.act() in this release. It ensures that the behavior in your tests matches what happens in the browser more closely. We recommend to wrap any code rendering and triggering updates to your components into act() calls. Testing libraries like react-testing-library can also wrap their APIs with it.

@reactjs-bot
Copy link

reactjs-bot commented Feb 5, 2019

Deploy preview for reactjs ready!

Built with commit 8fa112e

https://deploy-preview-1629--reactjs.netlify.com

});

it('can render and update a counter', () => {
// Test first render and componentDidMount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops this shouldn’t mention cDM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning, it should be “first render and effect”

expect(label.textContent).toBe('You clicked 0 times');
expect(document.title).toBe('You clicked 0 times');

// Test second render and componentDidUpdate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

});

it('can render and update a counter', () => {
// Test first render and componentDidMount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

expect(label.textContent).toBe('You clicked 0 times');
expect(document.title).toBe('You clicked 0 times');

// Test second render and componentDidUpdate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@gaearon
Copy link
Member

gaearon commented Feb 5, 2019

That's already in the blog post?

I mean Changelog section in the end which should match the Changelog PR in React repo and lists all important changes.

We haven’t added Sunil’s change there but we should. It’s a new API.

@bvaughn
Copy link
Contributor Author

bvaughn commented Feb 5, 2019

Hm. I guess it seems really redundant since it's mentioned so explicitly right above, but sure I'll sync whatever Andrew adds to the CHANGELOG once he's added it.

@gaearon
Copy link
Member

gaearon commented Feb 5, 2019

By that logic we could also remove Hooks PR from it since Hooks are also mentioned :-)

We generally leave blog changelog consistent with what’s on GH release and in Changelog.md in the repo. It’s more of a detailed look if you want to see which PR implemented what, and the discussion. Or if you got breakage and want to see the exact list of changes. Whereas body of blog post is a friendly summary.

@bvaughn
Copy link
Contributor Author

bvaughn commented Feb 5, 2019

That's fine. I wasn't arguing against it, just saying it seemed redundant. I already pushed the update, as you'll see above 😄

@gaearon
Copy link
Member

gaearon commented Feb 5, 2019

Yeah I just wanted to explain why. It’s intentionally redundant. :-)

I forgot this but we should probably also add TestRenderer.act() to the reference. Maybe just “Same as TestUtils.act() but for the test renderer” with an explanation link.

Not urgent tho because RN doesn’t have hooks yet anyway.

@bvaughn bvaughn merged commit d468ba1 into reactjs:master Feb 6, 2019
@bvaughn bvaughn deleted the hooks-stable branch February 6, 2019 08:05
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants