-
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
7d5226c
commit a37c7ab
Showing
47 changed files
with
1,240 additions
and
230 deletions.
There are no files selected for viewing
Binary file not shown.
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 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,15 @@ | ||
import init from 'jooks'; | ||
import useValue from '../useValue'; | ||
|
||
|
||
describe('useValue hook', () => { | ||
const jooks = init(() => useValue(3)); | ||
|
||
it('should return the times with additional text', () => { | ||
// Act | ||
const text = jooks.run(); | ||
|
||
// Assert | ||
expect(text).toEqual(`You clicked 3 times`); | ||
}); | ||
}) |
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,20 @@ | ||
import React, { useState } from 'react'; | ||
import useValue from './useValue'; | ||
import useFunction from './useFunction'; | ||
import useComponent from './useComponent'; | ||
|
||
const AwesomeHooks = () => { | ||
const [state, setState] = useState(0); | ||
const value = useValue(state); | ||
const action = useFunction(setState); | ||
const Component = useComponent(() => action(state + 1)); | ||
|
||
return ( | ||
<div> | ||
<h1>Awesome hooks demo</h1> | ||
<Component><button>{value}</button></Component> | ||
</div> | ||
) | ||
} | ||
|
||
export default AwesomeHooks; |
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,11 @@ | ||
import React from 'react'; | ||
|
||
const useComponent = (action) => { | ||
const Component = ({ children }) => ( | ||
<div onClick={action}>{children}</div> | ||
); | ||
|
||
return Component; | ||
} | ||
|
||
export default useComponent; |
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 @@ | ||
const useFunction = action => { | ||
console.log('loaded'); | ||
return action; | ||
} | ||
|
||
export default useFunction; |
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,5 @@ | ||
const useValue = (value) => { | ||
return `You clicked ${value} times`; | ||
} | ||
|
||
export default useValue; |
Oops, something went wrong.