Skip to content

Commit

Permalink
feat: package (#35)
Browse files Browse the repository at this point in the history
* feat: package

* fix: tsconfig

* feat(readme): update contrib
  • Loading branch information
leomotors authored Oct 1, 2022
1 parent 1821350 commit 7346a18
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ dist-ssr
*.sln
*.sw?
.vercel

package
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A collection of [React Custom Hooks](https://reactjs.org/docs/hooks-custom.html)
- (Optional) ⭐️ This repository
- Create a new hook in `src/hooks` folder.
- Show example usage in `src/App.tsx`.
- If you don't know TypeScript, simply use `any` type or predefined [`DefinitelyNotAny`](./src/vite-env.d.ts) type
- If you don't know TypeScript, simply use `any` type or import `DefinitelyNotAny` from "./types"
- Try not to update other places or auto-format, it'll cause merge conflicts.

## TODOs
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
"preview": "vite preview",
"package": "tsc -p tsconfig.package.json && cp package.json package"
},
"dependencies": {
"react": "^18.2.0",
Expand All @@ -29,4 +30,4 @@
"typescript": "^4.8.4",
"vite": "^3.1.0"
}
}
}
1 change: 1 addition & 0 deletions src/hooks/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type DefinitelyNotAny = any
1 change: 1 addition & 0 deletions src/hooks/useAny.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMemo } from "react"
import { DefinitelyNotAny } from "./types"

export function useAny(value: DefinitelyNotAny): DefinitelyNotAny {
const result = useMemo(() => value as DefinitelyNotAny, [])
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useCuteAndFunny.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMemo } from "react"
import { DefinitelyNotAny } from "./types"

export function useCuteAndFunny(...args: DefinitelyNotAny[]) {
const result = useMemo(() => "😭", [])
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useLess.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from "react"
import { DefinitelyNotAny } from "./types"

export function useLess(initialValue: DefinitelyNotAny) {
const [value, _setValue] = useState(initialValue)
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useSmile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMemo } from "react"
import { DefinitelyNotAny } from "./types"

export function useSmile(...args: DefinitelyNotAny[]) {
const result = useMemo(() => "😊", [])
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useSus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMemo } from "react"
import { DefinitelyNotAny } from "./types"

export function useSus(...args: DefinitelyNotAny[]) {
const result = useMemo(() => "ඞ", [])
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useVoid.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useLayoutEffect } from "react"
import { DefinitelyNotAny } from "./types"

export function useVoid(...args: DefinitelyNotAny[]) {
useLayoutEffect(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/// <reference types="vite/client" />

type DefinitelyNotAny = any
10 changes: 10 additions & 0 deletions tsconfig.package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src/hooks",
"outDir": "./package",
"noEmit": false,
"declaration": true
},
"include": ["./src/hooks/**/*"]
}

1 comment on commit 7346a18

@vercel
Copy link

@vercel vercel bot commented on 7346a18 Oct 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-useless – ./

react-useless-git-main-notnarze.vercel.app
react-useless-notnarze.vercel.app
react-useless.vercel.app

Please sign in to comment.