Skip to content

Commit

Permalink
feat(clean): remove noRef helper because it is no longer needed for r…
Browse files Browse the repository at this point in the history
…eact-redux
  • Loading branch information
pgarciacamou committed Sep 15, 2019
1 parent bcc6959 commit 4e7a4f0
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 146 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Upgrade babel dependencies after greenkeeper based on https://github.com/transitive-bullshit/create-react-library/commit/df4d01feb28cba27ec5d0ffee6b107c1680be912#diff-272ba4df44ddd6215793bb638d2d239d
### Fixed
### Changed
- Removed `noRef` workarounds for `react-redux`. `React-redux` no longer throws an error when passing an object and if we want to forward a reference to the inner component, we can use `forwardRef` option or wrap the connected component. See: https://github.com/reduxjs/react-redux/issues/914#issuecomment-377421145 and https://react-redux.js.org/api/connect#forwardref-boolean.

## [v2.1.1](https://github.com/pgarciacamou/react-context-consumer-hoc/releases/tag/v2.1.1) - 2018-10-15
### Added
Expand Down
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,22 +226,6 @@ export default withContext(
)
```

#### noRef

`[withContext|withContextAsProps|UNSAFE_withContext].noRef`

`noRef` is a simple wrapper built on top of all APIs which wraps the topmost consumer with a stateless function component (a function). to work around the `react-redux -> connect()` bug with React.forwardRef, see issue #6 for more information.

```jsx
export default connect(
function mapStateToProps(state, ownProps) { /* ... */ }
)(
withContextAsProps.noRef(...)(MyComponent)
// or withContext.noRef([...], mapContextToProps)(MyComponent)
// or UNSAFE_withContext.noRef(...)(MyComponent)
)
```

## Author

* Pablo Garcia [@pgarciacamou](https://twitter.com/pgarciacamou/)
Expand Down
2 changes: 1 addition & 1 deletion example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import React from 'react'
import ReactDOM from 'react-dom'

import './index.css'
import App from 'react-context-consumer-hoc/example/src/App-v2'
import App from 'react-context-consumer-hoc/example/src/App-v3'

ReactDOM.render(<App />, document.getElementById('root'))
14 changes: 0 additions & 14 deletions src/UNSAFE_withContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,4 @@ function UNSAFE_withContext(...ContextAPIs) {
}
}

/**
* Temporary workaround to fix react-redux issue with forwardRef.
* This workaround will be removed on v3.
*
* Issue: https://github.com/pgarciacamou/react-context-consumer-hoc/issues/6
*/
function noRef(...ContextAPIs) {
return ComposedComponent => {
const Component = UNSAFE_withContext(...ContextAPIs)(ComposedComponent)
return props => (<Component {...props} />)
}
}

UNSAFE_withContext.noRef = noRef
export default UNSAFE_withContext
87 changes: 0 additions & 87 deletions src/__tests__/noRef.spec.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/withContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,4 @@ function withContext(ContextAPIs, mapContextToProps) {
}
}

/**
* Temporary workaround to fix react-redux issue with forwardRef.
* This workaround will be removed on v3.
*
* Issue: https://github.com/pgarciacamou/react-context-consumer-hoc/issues/6
*/
function noRef(ContextAPIs, mapContextToProps) {
return ComposedComponent => {
const Component = withContext(ContextAPIs, mapContextToProps)(ComposedComponent)
return props => (<Component {...props} />)
}
}

withContext.noRef = noRef
export default withContext
14 changes: 0 additions & 14 deletions src/withContextAsProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,4 @@ function withContextAsProps(...ContextAPIs) {
return withContext(ContextAPIs, mapContextToProps)
}

/**
* Temporary workaround to fix react-redux issue with forwardRef.
* This workaround will be removed on v3.
*
* Issue: https://github.com/pgarciacamou/react-context-consumer-hoc/issues/6
*/
function noRef(...ContextAPIs) {
return ComposedComponent => {
const Component = withContext(ContextAPIs, mapContextToProps)(ComposedComponent)
return props => (<Component {...props} />)
}
}

withContextAsProps.noRef = noRef
export default withContextAsProps

0 comments on commit 4e7a4f0

Please sign in to comment.