DEV Community

Discussion on: Publishing a React Hooks Library using Typescript and TSDX

Collapse
 
devhammed profile image
Hammed Oyedele

I will prefer to use create-react-hook instead because it will setup an example folder that you can deploy to GitHub pages. I once use it for a React hook for manipulating browser cookies.

GitHub logo devhammed / use-cookie

Get, Set, Update and Delete Cookie using React Hooks.

@devhammed/use-cookie

Get, Set, Update and Delete Cookie using React Hooks.

NPM JavaScript Style Guide

Install

npm install --save @devhammed/use-cookie

Usage

import React from 'react'
import ReactDOM from 'react-dom'
import useCookie from '@devhammed/use-cookie'
const App = () => {
  const [username, setUsername, deleteUsername] = useCookie('username', 'User')
  return (
    <section&gt
      <h1>Hello {username}!</h1&gt
      <p>Edit below input, Your name will be stored in a cookie. you can refresh this page to see how it persists.</p&gt
      <input
        type='text'
        value={username}
        onChange={(e) => setUsername(e.target.value)}
      />
      <button
        onClick={() => deleteUsername()}
      >
        Delete Cookie
      </button>
    </section>
  )
}

ReactDOM.render(<App />, 

GitHub logo Hermanya / create-react-hook

🎣CLI for easily creating reusable react hooks.

create-react-hook

CLI for creating reusable React hooks using Rollup and create-react-app Inspired by the amazing create-react-library

NPM Build Status JavaScript Style Guide

How and why I made this tool.

Features

  • Easy-to-use CLI
  • Handles all modern JS features
  • Bundles cjs and es module formats
  • create-react-app for example usage and local dev
  • Rollup for bundling
  • Babel for transpiling
  • Jest for testing
  • Supports complicated peer-dependencies
  • Optional support for TypeScript
  • Sourcemap creation

Install

This package requires node >= 4, but we recommend node >= 8.

npm install -g create-react-hook

Creating a New Hook

create-react-hook

Answer some basic prompts about your module, and then the CLI will perform the following steps:

  • copy over the template
  • install dependencies via yarn or npm
  • link packages together for local development
  • initialize local git repo

Development

Local development is broken into two parts (ideally using two tabs).

First, run rollup to watch your src/ module and automatically recompile it into dist/ whenever you…

Collapse
 
juliang profile image
Julian Garamendy

Awesome! I didn't know create-react-hook. Thank you!