diff --git a/components/button/index.js b/components/button/index.js index ae46d45..d0c420f 100644 --- a/components/button/index.js +++ b/components/button/index.js @@ -1,12 +1,18 @@ +const { + memoizeWith, +} = require('ramda'); + const r = require('r-dom'); +const ref = memoizeWith(autoFocus => String(Boolean(autoFocus)), autoFocus => input => { + if (input && autoFocus) { + input.focus(); + } +}); + const Button = props => r.button({ - ref: input => { - if (input && props.autoFocus) { - input.focus(); - } - }, + ref, className: 'button', ...props, }, props.children);