1.0.3 • Published 6 years ago

react-deepdefaultobjects v1.0.3

Weekly downloads
15
License
MIT
Repository
github
Last release
6 years ago

react-deepDefaultObjects

This higher order component (HOC) for react allows to consider nested objects as default properties.

Why should I use that?

  • Improve code readability: Allows to group logical related properties.
  • Max performance: Only loop and merge nested objects as the rest is done by react itself anyway.
  • No side effects: No 3rd party dependencies where used.

How to use

  1. install the dependency
    // with npm
    npm install react-deepdefaultobjects

    // with yarn
    yarn add react-deepdefaultobjects
  1. import and use it where you need nested default objects
import deepDefaultObjects from 'react-deepDefaultObjects';

class yourComponent extends React.Component {
    // your code
};

yourComponent.defaultProps = {
    nestedObject: {
        nestString: 'default',
        anotherNumber: 42,
    },
};

export default deepDefaultObjects(yourComponent);

Debug

To debug this component you need to install node_modules first

    // with npm
    npm install

    // with yarn
    yarn add

For manual debugging run npm start or yarn start.

For automated tests run npm run test or yarn test`.