forked from acdlite/recompose
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add CHANGELOG.md * add lifecycle example in docs * filter packages by the existence of a package.json file (acdlite#575) * use static class properties to convert toClass implicit return arrow * Adding an optional callback argument to the `dispatch` method provided by `withReducer` * Fix babel-plugin-lodash name on readme (acdlite#606) * Add a debugging section in README * Fix a typo in README * Update docs & readme * babel-preset-es2015 -> babel-preset-env * change rest element to be the last in restructuring * Pass blacklist argument to hoist-non-react-statics using hoistStatics * Add blacklist docs for hoistStatics (acdlite#635) * Refactor rollup config (acdlite#645) - move all bundles into dist folder - add size snapshot - remove treeshake test * Update dependencies before changes according to React 16.3+ (acdlite#646) * New lifecycles support (acdlite#647) * Remove cache from withHandlers * Update createSink * Update withPropsOnChange * remove memoize as useless * Simplify code * Include flow types into library (acdlite#649) * Fix types for modern flow * Move flow declarations and test into recompose * Fix docs * Remove errors * Add yarn-error to gitignore * Append flow 2 test * Update release to support flow types * Remove unneeded command * recompose v0.27.0 * chore: update yarn.lock * chore: update yarn.lock * fix: fix scripts * fix: remove flow command in test
- Loading branch information
1 parent
e50be07
commit 0a3819d
Showing
55 changed files
with
3,258 additions
and
1,514 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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[ignore] | ||
<PROJECT_ROOT>/types/.* | ||
|
||
[include] | ||
|
||
[libs] | ||
../flow-typed/recompose_v0.24.x/flow_v0.55.x-/recompose_v0.24.x.js | ||
|
||
[options] | ||
suppress_comment=\\(.\\|\n\\)*\\$ExpectError | ||
|
||
[lints] | ||
[lints] |
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ release | |
lib | ||
coverage | ||
.vscode | ||
yarn-error.log | ||
_book |
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,2 @@ | ||
node_modules | ||
package.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,3 @@ | ||
semi: false | ||
singleQuote: true | ||
trailingComma: es5 |
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 @@ | ||
{ | ||
"lib/packages/recompose/dist/Recompose.umd.js": { | ||
"bundled": 78789, | ||
"minified": 29082, | ||
"gzipped": 9356 | ||
}, | ||
"lib/packages/recompose/dist/Recompose.min.js": { | ||
"bundled": 75283, | ||
"minified": 27833, | ||
"gzipped": 8952 | ||
}, | ||
"lib/packages/recompose/dist/Recompose.esm.js": { | ||
"bundled": 31265, | ||
"minified": 15642, | ||
"gzipped": 3464, | ||
"treeshaked": { | ||
"rollup": 569, | ||
"webpack": 1797 | ||
} | ||
} | ||
} |
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,92 @@ | ||
# Flow support for recompose | ||
|
||
## How it works | ||
|
||
In most cases all you need is to declare a props type of enhanced Component. | ||
Flow will infer all other types you need. | ||
|
||
Example: | ||
|
||
```javascript | ||
import type { HOC } from 'recompose'; | ||
|
||
type EnhancedComponentProps = { | ||
text?: string, | ||
}; | ||
|
||
const baseComponent = ({ text }) => <div>{text}</div>; | ||
|
||
const enhance:HOC<*, EnhancedComponentProps> = compose( | ||
defaultProps({ | ||
text: 'world', | ||
}), | ||
withProps(({ text }) => ({ | ||
text: `Hello ${text}` | ||
})) | ||
); | ||
|
||
export default enhance(baseComponent); | ||
|
||
``` | ||
|
||
See it in action. | ||
|
||
![recompose-flow](https://user-images.githubusercontent.com/5077042/28116959-0c96ae2c-6714-11e7-930e-b1454c629908.gif) | ||
|
||
## How to start | ||
|
||
The easiest way is to start from example. | ||
|
||
Look at [this](http://grader-meets-16837.netlify.com/) app [source](../types/flow-example) | ||
|
||
|
||
## Support | ||
|
||
Type definitions of recompose HOCs are splitted into 2 parts. | ||
|
||
### Part 1 - HOCs with good flow support | ||
|
||
In most cases you can use them without big issues. | ||
Type inference and errors detection works near well. | ||
|
||
These HOCs are: *defaultProps, mapProps, withProps, withStateHandlers, withHandlers, pure, onlyUpdateForKeys, shouldUpdate, renderNothing, renderComponent, branch, withPropsOnChange, onlyUpdateForPropTypes, toClass, withContext, getContext, setStatic, setPropTypes, setDisplayName* | ||
|
||
#### Known issues for "good" HOCs | ||
|
||
see `test_mapProps.js` - inference work but type errors are not detected in hocs | ||
|
||
### Part 2 - other HOCs | ||
|
||
To use these HOCs - you need to provide type information (no automatic type inference). | ||
You must be a good voodoo dancer. | ||
|
||
See `test_voodoo.js` for the idea. | ||
|
||
Some recomendations: | ||
|
||
- *flattenProp,renameProp, renameProps* can easily be replaced with _withProps_ | ||
- *withReducer, withState* -> use _withStateHandlers_ instead | ||
- _lifecycle_ -> you don't need recompose if you need a _lifecycle_, just use React class instead | ||
- _mapPropsStream_ -> see `test_mapPropsStream.js` | ||
|
||
#### Known issues for above HOCs | ||
|
||
See `test_voodoo.js`, `test_mapPropsStream.js` | ||
|
||
### Utils | ||
|
||
*getDisplayName, wrapDisplayName, shallowEqual,isClassComponent, createSink, componentFromProp, nest, hoistStatics.* | ||
|
||
### Articles | ||
|
||
[Typing Higher-order Components in Recompose With Flow](https://medium.com/flow-type/flow-support-in-recompose-1b76f58f4cfc) | ||
|
||
### Faq | ||
|
||
Why to use existential type with `HOC<*, Blbla>` isn't it possible to avoid this? | ||
|
||
*I tried to use type alias but haven't found how to make it work.* | ||
|
||
## Thanks | ||
|
||
Big thanks to [@gcanti](https://github.com/gcanti) for his work on PR [#241](https://github.com/acdlite/recompose/pull/241), it was nice and clear base for current definitions. |
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 |
---|---|---|
@@ -1,2 +1,7 @@ | ||
/* eslint-disable */ | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000 | ||
|
||
import Enzyme from 'enzyme' | ||
import Adapter from 'enzyme-adapter-react-16' | ||
|
||
Enzyme.configure({ adapter: new Adapter() }) |
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
Oops, something went wrong.