├── files ├── .gitignore ├── test-setup.js ├── index.d.ts ├── index.js.flow ├── index.js ├── .travis.yml ├── example.js ├── example.html ├── test.js ├── README.md ├── package.json └── LICENSE ├── init.sh ├── init.bat └── README.md /files/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | dist 4 | .cache 5 | -------------------------------------------------------------------------------- /init.sh: -------------------------------------------------------------------------------- 1 | cp -r ./files $1 2 | cd $1 3 | git init . 4 | yarn 5 | -------------------------------------------------------------------------------- /init.bat: -------------------------------------------------------------------------------- 1 | xcopy.exe /s .\files %1 2 | cd %1 3 | git init . 4 | yarn -------------------------------------------------------------------------------- /files/test-setup.js: -------------------------------------------------------------------------------- 1 | require('raf/polyfill'); 2 | require('browser-env')(); 3 | -------------------------------------------------------------------------------- /files/index.d.ts: -------------------------------------------------------------------------------- 1 | interface ... { 2 | // ... 3 | } 4 | 5 | export default function use...(): ...; 6 | -------------------------------------------------------------------------------- /files/index.js.flow: -------------------------------------------------------------------------------- 1 | interface ... { 2 | // ... 3 | } 4 | 5 | declare export default function use...(): ...; 6 | -------------------------------------------------------------------------------- /files/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | let { useState } = require('react'); 3 | 4 | function use...() { 5 | return; 6 | } 7 | 8 | module.exports = use...; 9 | -------------------------------------------------------------------------------- /files/.travis.yml: -------------------------------------------------------------------------------- 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 13 | -------------------------------------------------------------------------------- /files/example.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from 'react-dom'; 3 | import use... from './'; 4 | 5 | function App() { 6 | let value = use...(); 7 | return
; 8 | } 9 | 10 | render(, window.root); 11 | -------------------------------------------------------------------------------- /files/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Example 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /files/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | let test = require('ava'); 3 | let { createElement: h } = require('react'); 4 | let ReactTestRenderer = require('react-test-renderer'); 5 | let use... = require('./'); 6 | 7 | function render(val) { 8 | return ReactTestRenderer.create(val); 9 | } 10 | 11 | test(t => { 12 | function Component() { 13 | let value = use...(); 14 | return h('div'); 15 | } 16 | 17 | let input = render(h(Component)); 18 | 19 | t.is(input.toJSON().props.value, '...'); 20 | }); 21 | -------------------------------------------------------------------------------- /files/README.md: -------------------------------------------------------------------------------- 1 | # `@rehooks/...` 2 | 3 | > React hook for ... 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/... 14 | ``` 15 | 16 | ## Usage 17 | 18 | ```js 19 | import use... from '@rehooks/...'; 20 | 21 | function MyComponent() { 22 | let value = use...(); 23 | // value == ... 24 | return
; 25 | } 26 | ``` 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rehooks-template 2 | 3 | This repo will help you when contributing a new React Hook to the `rehooks` org. 4 | 5 | 1. Clone this repository 6 | 1. `cd` into it 7 | 1. Run `./init.sh ../path/to/rehooks-desired-project-name` (run `./init.bat` if you are on windows) 8 | 1. `cd` into that directory 9 | 1. Open it up your editor 10 | 1. Find-all occurences of "..." across the entire project 11 | 1. Fill each of them in with the correct content 12 | 1. Be sure to run `yarn test` and `yarn example` and make sure it has the right behavior 13 | 1. Be sure to update the documentation and example 14 | 1. When you're done, create a repo and ping @jamiebuilds (github or twitter) 15 | -------------------------------------------------------------------------------- /files/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rehooks/...", 3 | "version": "1.0.0", 4 | "description": "React hook for ...", 5 | "main": "index.js", 6 | "repository": "https://github.com/rehooks/...", 7 | "author": "...", 8 | "license": "MIT", 9 | "publishConfig": { 10 | "access": "public" 11 | }, 12 | "keywords": [ 13 | "react", 14 | "hooks", 15 | "..." 16 | ], 17 | "files": [ 18 | "index.*" 19 | ], 20 | "scripts": { 21 | "test": "ava test.js", 22 | "example": "parcel example.html" 23 | }, 24 | "peerDependencies": { 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": "^16.7.0-alpha.0", 33 | "react-dom": "^16.7.0-alpha.0", 34 | "react-test-renderer": "^16.7.0-alpha.0" 35 | }, 36 | "ava": { 37 | "require": [ 38 | "./test-setup.js" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /files/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018-present ... 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. 20 | --------------------------------------------------------------------------------