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

feat(useFavicon): port useFavicon from react-use #386

Closed
wants to merge 4 commits into from

Conversation

alexnaiman
Copy link

What new hook does?

Checklist

  • Have you read contribution guideline?
  • Does the code have comments in hard-to-understand areas?
  • Is there an existing issue for this PR?
  • Have the files been linted and formatted?
  • Have the docs been updated?
  • Have the tests been added to cover new hook?
  • Have you run the tests locally to confirm they pass?

src/useFavicon/useFavicon.ts Outdated Show resolved Hide resolved
Change from `document.getElementsByTagName('head')` to `document.head.`
@alexnaiman
Copy link
Author

@septs If the pull request is merged/accepted, could you please add the hacktoberfest-accepted label?

@septs
Copy link

septs commented Oct 10, 2021

Sorry, i am not a maintainer

# Conflicts:
#	src/index.ts
…ve example

This commit adds remaining things that are required for adding this hook to the library. Missing
documentation is added, example is improved, ESLint warnings fixed and import style fixed.

re react-hookz#33
@codecov
Copy link

codecov bot commented Oct 30, 2022

Codecov Report

Merging #386 (0371976) into master (532cc41) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #386   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           61        62    +1     
  Lines         1065      1075   +10     
  Branches       184       186    +2     
=========================================
+ Hits          1065      1075   +10     
Impacted Files Coverage Δ
src/index.ts 100.00% <100.00%> (ø)
src/useFavicon/useFavicon.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ArttuOll
Copy link
Contributor

ArttuOll commented Oct 30, 2022

I noticed that this PR is quite old, so I figured it was time to give it some love.

I went over this PR and fixed things that needed to be fixed in order for this to be merged (added missing documentation, improved example, refactored code a little). Let's review this and get this one merged!

The biggest code change I made is changing the link rel from "shortcut icon" to just "icon". The "shortcut" link type is legacy and should not be used anymore, as explained in MDN (check the explanation for the "icon" link type).

@xobotyi
Copy link
Contributor

xobotyi commented Oct 30, 2022

Ah, about this one. i'm still making my mind, but tipping to decision not to implement hooks that modify <head> contents since it is more complicated that just throwing elements there. There is a better library called react-helmet and react-helmet-async doing this job pretty well, and, in most cases, even better and in more versatile than any hook possible.

@ArttuOll
Copy link
Contributor

Ah, about this one. i'm still making my mind, but tipping to decision not to implement hooks that modify contents since it is more complicated that just throwing elements there. There is a better library called react-helmet and react-helmet-async doing this job pretty well, and, in most cases, even better and in more versatile than any hook possible.

Just had a look at react-helmet-async, and fair enough, there seems to be more to the SSR side than I imagined.

Could you write your thoughts like this to the pull requests in the future? That way we would all be on the same page and unnecessary work could be avoided.

Should we close this one then and add a mention to the docs that this one will not be implemented?

ArttuOll added a commit that referenced this pull request Nov 4, 2022
…eFavicon

Hooks that modify contents of the head element will not be implemented, as discussed in #386.

closes #386
@ArttuOll
Copy link
Contributor

ArttuOll commented Nov 4, 2022

but tipping to decision not to implement hooks that modify contents

What are going to do with useDocumentTitle then? Deprecate it or keep it?

@xobotyi
Copy link
Contributor

xobotyi commented Nov 4, 2022

  1. this hook has to be rejected
  2. we have to remove hooks modifying <head> contents (yes, it is a breaking change)
  3. we have to add clarification on migration guide (docs) with suggestions to use react-helmet or react-helmet-async
  4. we have to add clarification notes to issue with migration list

@ArttuOll
Copy link
Contributor

ArttuOll commented Nov 4, 2022

  1. this hook has to be rejected
  2. we have to remove hooks modifying <head> contents (yes, it is a breaking change)
  3. we have to add clarification on migration guide (docs) with suggestions to use react-helmet or react-helmet-async
  4. we have to add clarification notes to issue with migration list

Sounds good!

ArttuOll added a commit that referenced this pull request Nov 4, 2022
Removing this hook since it has been decided that hooks which modify contents of the head element
should not be included in this library.

BREAKING CHANGE: useDocumentTitle has been removed.
re #386
ArttuOll added a commit that referenced this pull request Nov 9, 2022
* docs(migrating-from-react-use): Add mention about not implementing useFavicon

Hooks that modify contents of the head element will not be implemented, as discussed in #386.

closes #386

* docs(migrating-from-react-use): Fix typos and spellling errors

* feat(useDocumentTitle): Remove useDocumentTitle

Removing this hook since it has been decided that hooks which modify contents of the head element
should not be included in this library.

BREAKING CHANGE: useDocumentTitle has been removed.
re #386
github-actions bot pushed a commit that referenced this pull request Nov 9, 2022
# [18.0.0](v17.0.1...v18.0.0) (2022-11-09)

* Remove hooks that modify the head element (#1004) ([12f723d](12f723d)), closes [#1004](#1004) [#386](#386) [#386](#386) [#386](#386)

### BREAKING CHANGES

* useDocumentTitle has been removed.
@xobotyi
Copy link
Contributor

xobotyi commented Nov 9, 2022

🎉 This issue has been resolved in version 18.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

4 participants