Coder Social home page Coder Social logo

lp-hoc's Introduction

npm version

lp-hoc

A set of React higher order components (HOCs).

Higher order components wrap components to give them extra functionality. For instance, defining a callback to be triggered when a component mounts:

import { onMount } from '@launchpadlab/lp-hoc'

function MyComponent() {
  return <div>I'm a component</div>
}

function myMountFunction(props) {
  // will be called when component mounts
}

export default onMount(myMountFunction)(MyComponent)

HOCs allow you to replicate the functionality of class-based components using functional components. The HOCs in this library can be combined with those from recompose- in fact, you can think of this library as an extension to that one.

A list of all available HOCs can be found in the documentation.

A note about hooks

The use case of HOCs has been largely addressed by the addition of React hooks in v16.8. If possible, we recommend you use hooks instead of HOCs when building new components.

Here's a handy reference for determining which hooks solve for the use-cases of lp-hoc components (corresponding recompose components in parentheses):

  1. getSet (withState) -> useState
  2. modifyProps (withProps) -> useMemo and useCallback
  3. onMount -> useEffect
  4. onUnmount -> useEffect
  5. onUpdate -> useEffect
  6. waitFor -> if statements

Documentation

Documentation and usage info can be found in docs.md.

Migration Guides

Contribution

This package follows the Opex NPM package guidelines. Please refer to the linked document for information on contributing, testing and versioning.

Additional info

Cherry-picking imports

Along with ES module support, this library supports cherry-picked imports from the lib folder to reduce bundle sizes:

import onUpdate from '@launchpadlab/lp-hoc/lib/onUpdate'
import onMount from '@launchpadlab/lp-hoc/lib/onMount'

You can also combine this feature with babel-plugin-transform-imports to cherry-pick imports by default:

// .babelrc
{
    "plugins": [
        ["transform-imports", {
            "@launchpadlab/lp-hoc": {
                "transform": "@launchpadlab/lp-hoc/lib/${member}",
                "preventFullImport": true
            }
        }]
    ]
}

Size Limit

This library uses size-limit to prevent size bloat. The yarn size script is run in CI to check that the package size is under the limit specified in .size-limit.js. For a visualization of this package's relative dependency sizes, you can run yarn size --why.

lp-hoc's People

Contributors

dpikt avatar chawes13 avatar greenkeeper[bot] avatar renovate[bot] avatar aalejandromr avatar

Stargazers

 avatar

Watchers

Brendan Hennessy avatar James Cloos avatar Josias Schneider avatar Lanny Bose avatar Daniel M. avatar Angel Medina avatar  avatar George Lee avatar Monique Marchwiany avatar  avatar Alvaro Sanchez Diaz avatar Brett Lynch avatar  avatar  avatar

lp-hoc's Issues

An in-range update of enzyme is breaking the build ๐Ÿšจ

There have been updates to the enzyme monorepo:

    • The devDependency enzyme was updated from 3.5.1 to 3.6.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the enzyme group definition.

enzyme is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ versioning/versionator: Invalid version 2.9.0 <= Master version 2.9.0 (Details).
  • โœ… continuous-integration/codeship: Build succeeded (Details).
  • โœ… continuous-integration/travis-ci/push: The Travis CI build passed (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of react is breaking the build ๐Ÿšจ

There have been updates to the react monorepoundefined

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the react group definition.

react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ versioning/versionator: Invalid version 2.9.0 <= Master version 2.9.0 (Details).
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v16.5.1

16.5.1 (September 13, 2018)

React

  • Improve the warning when React.forwardRef receives an unexpected number of arguments. (@andresroberto in #13636)

React DOM

  • Fix a regression in unstable exports used by React Native Web. (@aweary in #13598)
  • Fix a crash when component defines a method called isReactComponent. (@gaearon in #13608)
  • Fix a crash in development mode in IE9 when printing a warning. (@link-alex in #13620)
  • Provide a better error message when running react-dom/profiling with schedule/tracking. (@bvaughn in #13605)
  • If a ForwardRef component defines a displayName, use it in warnings. (@probablyup in #13615)

Schedule (Experimental)

  • Add a separate profiling entry point at schedule/tracking-profiling. (@bvaughn in #13605)
FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Add withFormikAdapter

It'd be nice to standardize this across apps. While technically it is an HOC, it might make more sense to include it as an exported util within lp-components?

Add `onError` HOC

Hooks into new (React 16) componentDidCatch lifecycle method. Should be backwards compatible with React 15, print warning if not supported.

An in-range update of lodash is breaking the build ๐Ÿšจ

The dependency lodash was updated from 4.17.10 to 4.17.11.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

lodash is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • โŒ versioning/versionator: Invalid version 2.9.0 <= Master version 2.9.0 (Details).
  • โœ… continuous-integration/travis-ci/push: The Travis CI build passed (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of redux-modal is breaking the build ๐Ÿšจ

The dependency redux-modal was updated from 2.0.3 to 2.0.4.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

redux-modal is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • โŒ versioning/versionator: Invalid version 2.9.0 <= Master version 2.9.0 (Details).
  • โŒ continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).

Release Notes for Release 2.0.4
  • Delete destroy modal state key insteat set it to undefined (15a9094)
  • Merge pull request #71 from yesmeck/greenkeeper/monorepo.enzyme-1.8.0 (85a32fe)
  • chore(package): update enzyme to version 3.6.0 (3676fc9)
  • Merge pull request #70 from yesmeck/greenkeeper/monorepo.enzyme-1.4.0 (717db69)
  • chore(package): update enzyme-adapter-react-16 to version 1.4.0 (c623e2b)
  • chore(package): update enzyme to version 3.5.1 (ae5f34a)
  • Create LICENSE (413c27c)
  • Merge pull request #69 from yesmeck/greenkeeper/monorepo.enzyme-1.6.0 (53986c7)
  • chore(package): update enzyme-adapter-react-16 to version 1.2.0 (6b09c1b)
  • chore(package): update enzyme to version 3.4.4 (9e13bf4)
  • remove node 9 (d905e0e)
  • add testurl (ae0df44)
  • Merge pull request #59 from yesmeck/greenkeeper/hoist-non-react-statics-3.0.0 (167ce66)
  • fix(package): update hoist-non-react-statics to version 3.0.0 (57c5686)
  • Merge pull request #54 from yesmeck/greenkeeper/ts-jest-23.0.0 (4090b0c)
  • chore(package): update ts-jest to version 23.0.0 (806fb55)
Commits

The new version differs by 17 commits.

  • f19d20a Release 2.0.4
  • 15a9094 Delete destroy modal state key insteat set it to undefined
  • 85a32fe Merge pull request #71 from yesmeck/greenkeeper/monorepo.enzyme-1.8.0
  • 3676fc9 chore(package): update enzyme to version 3.6.0
  • 717db69 Merge pull request #70 from yesmeck/greenkeeper/monorepo.enzyme-1.4.0
  • c623e2b chore(package): update enzyme-adapter-react-16 to version 1.4.0
  • ae5f34a chore(package): update enzyme to version 3.5.1
  • 413c27c Create LICENSE
  • 53986c7 Merge pull request #69 from yesmeck/greenkeeper/monorepo.enzyme-1.6.0
  • 6b09c1b chore(package): update enzyme-adapter-react-16 to version 1.2.0
  • 9e13bf4 chore(package): update enzyme to version 3.4.4
  • d905e0e remove node 9
  • ae0df44 add testurl
  • 167ce66 Merge pull request #59 from yesmeck/greenkeeper/hoist-non-react-statics-3.0.0
  • 57c5686 fix(package): update hoist-non-react-statics to version 3.0.0

There are 17 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Archived recompose dependency affecting the security vulnerabilities report for Snyk

It seems like the recompose library we use to display the name of the HOC is not being maintained anymore and since it's a dependency of this repository it's affecting the security vulnerabilities report for Prosci.

Snyk is finding a Denial of Service vulnerability, because the node-fetch package version recompose, is using.

To my understanding we should not be using the part of the code that has the vulnerability because we are only using the wrapDisplayName function from recompose but I think is worth finding a replacement for the function we use knowing that the package is not going to be maintained anymore.

From the author of the recompose package:

Hooks solves all the problems I attempted to address with Recompose three years ago, and more on top of that. I will be discontinuing active maintenance of this package

We should explore which function could replace the wrapDisplayName function, or even mimic that function in a util ourselves. From what I can see in the codebase should be pretty straightforward.

If this sounds good I can assign this issue to myself.

Edit: Adding this report too https://security.snyk.io/vuln/SNYK-JS-NODEFETCH-2342118

Modal throws synthetic event warnings

A quick fix for this is to wrap the function in mapDispatchToProps in an anonymous function. Further investigation may be required to understand the "props" arguments that is expected and what the impact is of passing in undefined instead of the event from the onClick handler.

An in-range update of react-redux is breaking the build ๐Ÿšจ

The dependency react-redux was updated from 5.0.7 to 5.1.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

react-redux is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • โŒ versioning/versionator: Invalid version 2.9.0 <= Master version 2.9.0 (Details).
  • โœ… continuous-integration/travis-ci/push: The Travis CI build passed (Details).

Release Notes for v5.1.0

The biggest fix is for connect() being used with React's newer forwardRef, memo, and lazy APIs.

We also have begun a complete rewrite of our docs for React Redux. Check them out! Many thanks to those who contributed: @markerikson, @sveinpg, @wgao19, @BTMPL, @pyliaorachel, @dagstuan, @Kerumen, and @carloluis (sorry if I forgot someone!). Docs are a great way to get started contributing to open source, so open a PR today! Check #1001 to see what else needs to be done.

We're also looking at overhauling Redux's documentation. Check out reduxjs/redux#2590 for the latest there.

Changes

Commits

The new version differs by 56 commits.

  • b245f83 5.1.0
  • 307f463 Rebuild lock files with npm 6.4.1
  • 1b43eaa (feat): support react 16.6 (#1062)
  • 2093fbb Upgrade to babel@7 (#1043)
  • bc7b6a9 docs: enable search for docusaurus site (#1060)
  • 1e93536 Add nodejs version 10 for ci (#1058)
  • 1ab1596 fix log message hint for ownProps on map function (#1056)
  • 0d9325e Docs/refactor getting started (#1054)
  • ba6b010 Update docs link
  • dde1a0a Clean-Ups after mapState (#1042)
  • 294c42c [Docs] Fix duplicated words in mapState (#1037)
  • 05f943d Fixed broked links in footer (#1041)
  • cde9c04 Fix a very small typo in mapStateToProps docs (#1040)
  • 1db16a4 Fix link to getting started doc (#1039)
  • f930a76 Docs/extracting data with mapstate (#1036)

There are 56 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! ๐ŸŽŠ

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If youโ€™re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didnโ€™t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didnโ€™t touch job or matrix configurations because these tend to be quite specific and complex, and itโ€™s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what youโ€™re doing it may require additional work or may not be applicable at all. Weโ€™re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, Iโ€™m a humble robot and wonโ€™t feel rejected ๐Ÿค–


FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of codeclimate-test-reporter is breaking the build ๐Ÿšจ

The devDependency codeclimate-test-reporter was updated from 0.5.0 to 0.5.1.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

codeclimate-test-reporter is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ versioning/versionator: Invalid version 2.9.0 <= Master version 2.9.0 (Details).
  • โœ… continuous-integration/codeship: Build succeeded (Details).
  • โœ… continuous-integration/travis-ci/push: The Travis CI build passed (Details).

Commits

The new version differs by 5 commits.

  • 1ad7ea8 Bump to 0.5.1
  • 5e4b10e chore: update dependencies with security issues fixes #70
  • c4b55e1 README: update deprecation notice
  • 7a8c75f Update README.md
  • c37a8da Update README.md (#63)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.
  • WARN: Error updating PR

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm @babel/polyfill Unavailable
npm codeclimate-test-reporter Unavailable

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency query-string to v9
  • Update dependency react-redux to v9
  • Update dependency redux to v5
  • Update dependency size-limit to v11
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @launchpadlab/lp-requests ^4.1.6
  • classnames ^2.2.5
  • humps ^2.0.1
  • lodash ^4.17.4
  • prop-types ^15.5.8
  • query-string ^5.1.1
  • react-body-classname ^1.2.0
  • react-modal ^3.10.1
  • recompose ^0.26.0
  • redux ^4.0.0
  • @babel/cli ^7.4.4
  • @babel/core ^7.4.5
  • @babel/polyfill ^7.7.0
  • @launchpadlab/babel-preset ^2.1.0
  • @launchpadlab/eslint-config ^2.7.0
  • @size-limit/preset-small-lib ^3.0.0
  • codeclimate-test-reporter ^0.5.0
  • documentation ^12.1.4
  • enzyme ^3.2.0
  • enzyme-adapter-react-16 ^1.11.2
  • eslint ^6.1.0
  • husky ^4.2.1
  • isomorphic-fetch ^2.2.1
  • jest ^25.1.0
  • react ^16.4.0
  • react-dom ^16.4.0
  • react-redux ^7.1.1
  • react-router ^5.0.0
  • react-router-dom ^5.0.0
  • react-router-v3 ^3.0.0
  • redux-modal ^4.0.0
  • size-limit ^3.0.0
  • react ^15.5.4 || ^16.4.0
  • react-redux ^5.0.6 || ^6.0.1 || ^7.0.0
  • react-router ^3.0.0 || ^4.0.0 || ^5.0.0
  • redux-modal ^2.0.2 || ^3.0.1 || ^4.0.0
nvm
.nvmrc
  • node v10
travis
.travis.yml
  • node 10

  • Check this box to trigger a request for Renovate to run again on this repository

An in-range update of @launchpadlab/lp-requests is breaking the build ๐Ÿšจ

The dependency @launchpadlab/lp-requests was updated from 3.4.0 to 3.4.1.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@launchpadlab/lp-requests is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • โŒ versioning/versionator: Invalid version 2.9.0 <= Master version 2.9.0 (Details).
  • โŒ continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).

Commits

The new version differs by 1 commits.

  • 1c3f9b0 Downgrade to query-string v5 for browser compatibility (#55)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.