Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update docs to use hooks #271

Merged
merged 8 commits into from
Oct 3, 2019
Merged

Update docs to use hooks #271

merged 8 commits into from
Oct 3, 2019

Conversation

selbekk
Copy link
Contributor

@selbekk selbekk commented Sep 8, 2019

This pull request goes through all the different docs, and does the following:

  • removes usage of component-component in favor of function components with hooks
  • refactors class component examples to use function components and hooks
  • standardize all example component names to Example
  • Fix a few typos, broken links and what not

Fixes #269

@selbekk
Copy link
Contributor Author

selbekk commented Sep 8, 2019

I see I've done some unintended changes to the formatting as well with my prettier setup. Looks like there isn't a prettier config file present in the project - not sure what to do about those changes. They look the same rendered, so perhaps it's not a huge deal 😄

@tomByrer
Copy link

Great idea! Many of the examples are much shorter with hooks.

Some issues though; are the new examples comparable with Preact & Inferno? Obviously React is the target framework, but that isn't the only JSX renderer. Plus, some folks may want the old class-based code for their own reasons. Possible to have both in a tabbed selector or something? Side effect; if someone is refactoring FROM classes to fucntions+hooks, both examples could help guide them.

Thoughts anyone else?

@selbekk
Copy link
Contributor Author

selbekk commented Sep 12, 2019

These all sounds like new features to me - features worth discussing in an issue, perhaps? 🙂 I'd love to take part of that discussion :)

Preact has support for hooks, Inferno doesn't (yet).

@@ -42,36 +42,32 @@ Hook that observes and returns the measurements (ClientRect) of a DOM element. P
If `observe` is false, the element's rect will no longer be observed, pass it `true` again and it will. This is mostly used for things like popovers and animations, so you can usually observe when you need to, and stop observing when you don't.

```.jsx
(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the iife?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When there’s a single component in a code block, it will call it automatically. In my head, keeping the iife was just unneccesary syntax noise.

Copy link
Member

Choose a reason for hiding this comment

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

I asked @ryanflorence about it and he said the reason he originally used the iife's was because react-live needs a component instance to be returned, not the component class itself. Is that not the case here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm okay, I don’t think that’s the case anymore at least. I’m on my phone right noe, but the gif on their readme looks like a regular function. Perhaps they invoke it for you? 🤷‍♂️ I’ll verify tomorrow morning 🙌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep it's not needed anymore. You can check it yourself by going to https://ui.reach.tech/rect/ and removing the iife if you want :)

@mjackson
Copy link
Member

@selbekk Ah, we should probably add a Prettier config to this repo. Those trailing commas are going to annoy me ;)

@tomByrer If you'd like to add examples for Preact and/or Inferno let's discuss that in a separate issue. :)

@selbekk
Copy link
Contributor Author

selbekk commented Sep 19, 2019

That’s fine - sorry for budding in with my comma preferences 😄

@chaance
Copy link
Member

chaance commented Oct 2, 2019

@selbekk I've since added a prettier config and updated some docs through merging older PRs. If you could help us clean up some of the formatting changes and merge conflict, I'll be happy to merge. I think this looks great!

@chaance chaance added the Type: Documentation Changes to the docs label Oct 2, 2019
@selbekk
Copy link
Contributor Author

selbekk commented Oct 3, 2019

@chancestrickland - done son!

@chaance chaance merged commit 7367cd7 into reach:master Oct 3, 2019
chaance pushed a commit that referenced this pull request Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Changes to the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use hooks in examples instead of component^2
4 participants