forked from zaydek/heroicons.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the <DocumentTitle> pattern to <SearchBar>
- Loading branch information
Zaydek Michels-Gualtieri
committed
Apr 4, 2020
1 parent
992d43d
commit d469676
Showing
4 changed files
with
226 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from "react" | ||
|
||
// Sets the document title (uses useEffect). | ||
const DocumentTitle = ({ title, ...props }) => { | ||
React.useEffect(() => { | ||
if (!title) { | ||
// No-op | ||
return | ||
} | ||
document.title = title | ||
}, [title]) | ||
return props.children || null | ||
} | ||
|
||
const HeroiconsTitle = ({ title, ...props }) => { | ||
return <DocumentTitle title={title || "Heroicons"} {...props} /> | ||
} | ||
|
||
export default HeroiconsTitle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.