npm.io
1.0.3 • Published 8 years ago

react-deepdefaultobjects

Licence
MIT
Version
1.0.3
Deps
0
Size
43 kB
Vulns
0
Weekly
0

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`.

Keywords