forked from facebookarchive/redux-react-hook
-
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.
- Loading branch information
1 parent
92ee570
commit cf887c6
Showing
27 changed files
with
1,644 additions
and
17,705 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
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,21 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
import * as React from 'react'; | ||
import {useDispatch} from './Store'; | ||
|
||
export default function TodoInput() { | ||
const [newTodo, setNewTodo] = React.useState(''); | ||
const dispatch = useDispatch(); | ||
|
||
return ( | ||
<input | ||
type="text" | ||
onChange={e => setNewTodo(e.target.value)} | ||
onKeyDown={e => { | ||
if (e.key === 'Enter') { | ||
dispatch({type: 'add todo', todo: newTodo}); | ||
setNewTodo(''); | ||
} | ||
}} | ||
value={newTodo} | ||
/> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
import * as React from 'react'; | ||
import {IState, useDispatch, useMappedState} from './Store'; | ||
|
||
export default function TodoItem({index}: {index: number}) { | ||
const mapState = React.useCallback((state: IState) => state.todos[index], [ | ||
index, | ||
]); | ||
const todo = useMappedState(mapState); | ||
|
||
const dispatch = useDispatch(); | ||
const deleteTodo = React.useCallback( | ||
() => dispatch({type: 'delete todo', index}), | ||
[index], | ||
); | ||
|
||
return ( | ||
<li> | ||
<button onClick={deleteTodo}>x</button> {todo} | ||
</li> | ||
); | ||
} |
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 was deleted.
Oops, something went wrong.
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
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,15 @@ | ||
// Add hooks to the react typings | ||
declare module 'react' { | ||
export function useCallback<T>(callback: T, dependencies: Array<any>): T; | ||
export function useContext<T>(context: React.Context<T>): T; | ||
export function useEffect( | ||
didUpdate: () => (() => void) | void, | ||
dependencies?: Array<any>, | ||
): void; | ||
export function useRef<T>(initialValue?: T): {current: T}; | ||
export function useState<T>( | ||
initialState: T | (() => T), | ||
): [T, (newState: T | (() => T)) => void]; | ||
} | ||
|
||
export {}; |
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,31 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build/dist", | ||
"module": "esnext", | ||
"target": "es5", | ||
"lib": ["es6", "dom"], | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"jsx": "react", | ||
"moduleResolution": "node", | ||
"rootDir": "src", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": true, | ||
"importHelpers": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true | ||
}, | ||
"exclude": [ | ||
"build", | ||
"scripts", | ||
"acceptance-tests", | ||
"webpack", | ||
"jest", | ||
"src/setupTests.ts", | ||
"node_modules" | ||
] | ||
} |
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,3 @@ | ||
{ | ||
"extends": "./tsconfig.json" | ||
} |
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,6 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], | ||
"linterOptions": { | ||
"exclude": [ | ||
"config/**/*.js", | ||
"node_modules/**/*.ts", | ||
"coverage/lcov-report/*.js" | ||
] | ||
}, | ||
"rules": { | ||
"jsx-no-lambda": false | ||
} | ||
} |
Oops, something went wrong.