Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit481a180

Browse files
Init
0 parents  commit481a180

File tree

13 files changed

+7689
-0
lines changed

13 files changed

+7689
-0
lines changed

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
*.log
3+
dist
4+
.cache

‎.travis.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
git:
2+
depth:1
3+
sudo:false
4+
language:node_js
5+
node_js:
6+
-'8'
7+
cache:
8+
yarn:true
9+
directories:
10+
-node_modules
11+
script:
12+
-yarn test

‎LICENSE‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018-present DocumentTitle
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

‎README.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#`@rehooks/DocumentTitle`
2+
3+
>React hook for DocumentTitle
4+
5+
>**Note:** This is using the new[React Hooks API Proposal](https://reactjs.org/docs/hooks-intro.html)
6+
>which is subject to change until React 16.7 final.
7+
>
8+
>You'll need to install`react`,`react-dom`, etc at`^16.7.0-alpha.0`
9+
10+
##Install
11+
12+
```sh
13+
yarn add @rehooks/DocumentTitle
14+
```
15+
16+
##Usage
17+
18+
```js
19+
importuseDocumentTitlefrom'@rehooks/DocumentTitle';
20+
21+
functionMyComponent() {
22+
let value=useDocumentTitle();
23+
// value == DocumentTitle
24+
return<div/>;
25+
}
26+
```

‎example.html‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="utf-8">
5+
<metaname="viewport"content="width=device-width, initial-scale=1.0">
6+
<metahttp-equiv="X-UA-Compatible"content="ie=edge">
7+
<title>Example</title>
8+
</head>
9+
<body>
10+
<divid="root"></div>
11+
<scriptsrc="./example.js"></script>
12+
</body>
13+
</html>

‎example.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
importReactfrom'react';
2+
import{render}from'react-dom';
3+
importuseDocumentTitlefrom'./';
4+
5+
functionApp(){
6+
useDocumentTitle('page Title');
7+
return<div/>;
8+
}
9+
10+
render(<App/>,window.root);

‎index.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exportdefaultfunctionuseDocumentTitle(title:string);

‎index.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
let{ useEffect}=require('react');
3+
4+
functionuseDocumentTitle(title){
5+
useEffect(()=>{
6+
document.title=title;
7+
},[title])
8+
}
9+
10+
module.exports=useDocumentTitle;

‎index.js.flow‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function useDocumentTitle(title: string);

‎package.json‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name":"@rehooks/document-title",
3+
"version":"1.0.0",
4+
"description":"React hook for updating document-title",
5+
"main":"index.js",
6+
"repository":"https://github.com/rehooks/document-title",
7+
"author":"Amit Solanki <amit.fash@gmail.com>",
8+
"license":"MIT",
9+
"publishConfig": {
10+
"access":"public"
11+
},
12+
"keywords": [
13+
"react",
14+
"hooks",
15+
"DocumentTitle"
16+
],
17+
"files": [
18+
"index.*"
19+
],
20+
"scripts": {
21+
"test":"ava test.js",
22+
"example":"parcel example.html"
23+
},
24+
"dependencies": {
25+
"react":"^16.7.0-alpha.0"
26+
},
27+
"devDependencies": {
28+
"ava":"^0.25.0",
29+
"browser-env":"^3.2.5",
30+
"parcel":"^1.10.3",
31+
"raf":"^3.4.0",
32+
"react-dom":"^16.7.0-alpha.0",
33+
"react-test-renderer":"^16.7.0-alpha.0"
34+
},
35+
"ava": {
36+
"require": [
37+
"./test-setup.js"
38+
]
39+
}
40+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp