How to use the recompose.mapProps function in recompose

To help you get started, we’ve selected a few recompose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NCI-GDC / portal-ui / modules / node_modules / @ncigdc / uikit / Notification.js View on Github external
if (!nextProps.delay || nextProps.delay > 0) {
        startTimer();
      }
    }

    // If notification is up, refresh timeout when id changes
    if (props.visible && props.id !== nextProps.id) {
      clearTimeout(timeoutId);
      if (!nextProps.delay || nextProps.delay > 0) {
        startTimer();
      }
    }

    return true;
  }),
  mapProps(({ setState, ...rest }) => ({
    close: () => {
      setState(() => false);
      if (timeoutId) clearTimeout(timeoutId);
    },
    ...rest,
  }))
);

/*----------------------------------------------------------------------------*/

export default enhance(Notification);
github Archakov06 / rgxp / src / containers / App.js View on Github external
fetchPatterns();
	}
});

const handlers = withHandlers({
	fetchPatterns: ({ setPatterns }) => () => {
		axios
			.get('http://5b3757f86223c40014605837.mockapi.io/patterns')
			.then(({ data }) => {
				setPatterns(data);
			})
			.catch(error => console.error(error));
	}
});

const replaceProps = mapProps(props => ({
	...props,
	dict: language[props.language],
	patterns: props.patterns.length
		? props.patterns
				.filter(item => {
					const searchQuery =
						props.location.search.indexOf('search=') >= 0
							? props.location.search.split('search=')[1]
							: props.searchQuery;
					return (
						(item.title.hasOwnProperty(props.language) &&
							item.title[props.language].toLowerCase().indexOf(searchQuery) >=
								0) ||
						item.tags.toLowerCase().indexOf(searchQuery) >= 0 ||
						(item.hasOwnProperty('description') &&
							item.description.hasOwnProperty(props.language) &&
github go-faast / faast-web / src / app / components / CoinIcon.jsx View on Github external
}),
  defaultProps({
    size: 'md'
  }),
  connect((state, props) => {
    const symbol = props.symbol
    if (symbol === 'ERC20') {
      return { src: Erc20Svg, fill: '#fff' }
    }
    let iconSrc = getAssetIconUrl(state, symbol)
    if (!iconSrc) {
      iconSrc = QuestionMarkSvg
    }
    return { src: iconSrc }
  }),
  mapProps((props) => omit(props, 'symbol', 'dispatch'))
)(Icon)
github go-faast / faast-web / src / app / components / Link.jsx View on Github external
}

export default compose(
  setDisplayName('FaastLink'),
  setPropTypes({
    ...Link.propTypes,
    merge: PropTypes.bool,
  }),
  defaultProps({
    merge: false
  }),
  withRouter,
  withProps(({ to, merge, location: current }) => ({
    to: stringifyLocationQs(merge ? mergeLocations(to, current) : to)
  })),
  mapProps((props) => omit(props, 'merge', 'match', 'location', 'history', 'staticContext'))
)(Link)
github sergeysova / rurarar / src / app / components / Layout / Layout.js View on Github external
import React, { PropTypes } from 'react'
import cn from 'classnames'
import { compose, mapProps } from 'recompose'
import stylesClasses from 'styles'
import { useSheet } from 'styles/jss'
import { Types, selectClasses } from 'styles/mixins'

const styles = {
  layout: {
    display: 'flex',
  },
}

const enhance = compose(
  useSheet(styles),
  mapProps(({ sheet: { classes }, ...props }) => ({
    ...props,
    classes: {
      ...classes,
      additional: selectClasses(props, stylesClasses.classes, ['padding', 'justifyContent', 'alignItems']),
    },
  })),
)

const Layout = ({ children, classes, className }) => (
  <div>{children}</div>
)

Layout.propTypes = {
  classes: PropTypes.object,

  children: PropTypes.node,
github acdlite / recompose / examples / todomvc / components / Footer.js View on Github external
Clear completed
  

const footerApi = {
  activeCount: PropTypes.number.isRequired,
  completedCount: PropTypes.number.isRequired,
  filter: PropTypes.string.isRequired,
  onClearCompleted: PropTypes.func.isRequired,
  onShow: PropTypes.func.isRequired
}

export default compose(
  onlyUpdateForPropTypes,
  setPropTypes(footerApi),
  renameProp('filter', 'selectedFilter'),
  mapProps(({ activeCount, selectedFilter, onShow, completedCount, onClearCompleted }) =&gt; ({
    todoCount: TodoCount({ activeCount }),
    FilterLink: withProps({ selectedFilter, onShow }, FilterLink),
    clearButton: completedCount &gt; 0 ? ClearButton({ onClearCompleted }) : null
  }))
)(Footer)
github quiltdata / quilt / catalog / app / containers / LanguageProvider / index.js View on Github external
export default composeComponent(
  'LanguageProvider',
  injectReducer(REDUX_KEY, reducer),
  connect(
    createSelector(
      makeSelectLocale(),
      (locale) =&gt; ({ locale }),
    ),
  ),
  setPropTypes({
    locale: PropTypes.string,
    messages: PropTypes.object,
    children: PropTypes.element.isRequired,
  }),
  mapProps(({ locale, messages, ...props }) =&gt; ({
    locale,
    key: locale,
    messages: messages[locale],
    ...props,
  })),
  ({ children, ...props }) =&gt; (
    
      {children}
    
  ),
)
github jplayer / react-jPlayer / src / components / gui / guiContainer.js View on Github external
}
  },
  componentDidUpdate(prevProps) {
    if (prevProps.startGuiFadeOut !== this.props.startGuiFadeOut) {
      this.startFade();
    }
  },
};

export default compose(
  connectWithId(mapStateToProps, {
    setOption,
  }),
  withHandlers(handlers),
  setLifecycle(lifecycle),
  mapProps(props => ({
    children: props.children,
    fullScreen: props.fullScreen,
    guiFadeOut: props.guiFadeOut,
    onMouseMove: props.onMouseMove,
  })),
)(GuiAnimation);
github coralproject / talk / client / coral-admin / src / routes / Configure / containers / OrganizationSettings.js View on Github external
${getSlotFragmentSpreads(slots, 'root')}
      }
    `,
    settings: gql`
      fragment TalkAdmin_OrganizationSettings_settings on Settings {
        organizationName
        organizationContactEmail
        ${getSlotFragmentSpreads(slots, 'settings')}
      }
    `,
  }),
  connect(
    mapStateToProps,
    mapDispatchToProps
  ),
  mapProps(({ root, settings, updatePending, errors, ...rest }) => ({
    slotPassthrough: {
      root,
      settings,
      updatePending,
      errors,
    },
    updatePending,
    settings,
    errors,
    ...rest,
  }))
)(OrganizationSettings);
github i-novus-llc / n2o-framework / frontend / n2o-framework / src / components / widgets / Card / CardItem.jsx View on Github external
* Данные
   */
  datasource: PropTypes.object,
};

CardItem.defaultProps = {
  rows: ['image', 'header', 'meta', 'text', 'extra'],
  linear: false,
  inverse: false,
  outline: false,
};

export { CardItem };
export default compose(
  setDisplayName('CardItem'),
  mapProps(({ datasource, ...rest }) => extend(datasource, rest))
)(CardItem);