babel-plugin-jsx-merge-props
Why?
It's annoying to use props that provided from multiple hooks.
const useFirstHook = ... return className style onClick ;; const useSecondHook = ... return value style onClick ;;
const MyComponent = const first = ; const second = ; const handleClick = ; return <input ="text" = = = /> ;
Or would be better to use some package like merge-props
,
but It's still little bit bothersome.
import mergeProps from 'merge-props'; const MyComponent = const first = ; const second = ; return <input ="text" /> ;
You can just write like below with this plugin.
import mergeProps from 'merge-props'; const MyComponent = const first = ; const second = ; return <input = ="text" /> ;
Installation
npm install --save-dev babel-plugin-jsx-merge-props
Usage
.babelrc
: