How to use the recompact.compose function in recompact

To help you get started, we’ve selected a few recompact 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 rainbow-me / rainbow / src / components / pager / Pager.js View on Github external
/>
    )}
  
);

Pager.propTypes = {
  controlsProps: PropTypes.shape(PagerControls.propTypes),
  currentIndex: PropTypes.number,
  dimensions: dimensionsPropType,
  onScroll: PropTypes.func,
  onScrollEndDrag: PropTypes.func,
  pages: PropTypes.arrayOf(pagerPagePropType),
  scrollEnabled: PropTypes.bool,
};

export default compose(
  withState('currentIndex', 'setCurrentIndex', 0),
  mapProps(({ dimensions, pages, ...props }) => ({
    ...props,
    dimensions,
    pages: pages.map(page => ({
      ...page,
      dimensions,
    })),
  })),
  withProps(({ pages }) => ({
    scrollEnabled: pages.length > 1,
  })),
  withHandlers({
    onScroll: ({ currentIndex, dimensions, setCurrentIndex }) => ({ nativeEvent }) => {
      const currentOffsetX = get(nativeEvent, 'contentOffset.x', 0);
github rainbow-me / rainbow / src / screens / SettingsModal.js View on Github external
);
};

SettingsModal.propTypes = {
  currentSettingsPage: PropTypes.oneOf(Object.values(SettingsPages)),
  navigation: PropTypes.object,
  onCloseModal: PropTypes.func,
  onPressBack: PropTypes.func,
  onPressImportSeedPhrase: PropTypes.func,
  onPressSection: PropTypes.func,
};

export default compose(
  withProps(({ navigation }) => ({
    currentSettingsPage: get(
      navigation,
      'state.params.section',
      SettingsPages.default
    ),
  })),
  withHandlers({
    onCloseModal: ({ navigation }) => () => navigation.goBack(),
    onPressBack: ({ navigation }) => () =>
      navigation.setParams({ section: SettingsPages.default }),
    onPressImportSeedPhrase: ({ navigation }) => () => {
      navigation.goBack();
      InteractionManager.runAfterInteractions(() => {
        navigation.navigate('ImportSeedPhraseSheet');
        StatusBar.setBarStyle('light-content');
github rainbow-me / rainbow / src / components / expanded-state / ChartExpandedState.js View on Github external
);

TokenExpandedState.propTypes = {
  change: PropTypes.string,
  changeDirection: PropTypes.bool,
  isOpen: PropTypes.bool,
  onPressSend: PropTypes.func,
  onPressSwap: PropTypes.func,
  price: PropTypes.string,
  selectedAsset: PropTypes.object,
  subtitle: PropTypes.string,
  title: PropTypes.string,
};

export default compose(
  withAccountData,
  withAccountSettings,
  withState('isOpen', 'setIsOpen', false),
  withProps(({ asset: { address, ...asset }, assets }) => {
    let selectedAsset = ethereumUtils.getAsset(assets, address);
    if (!selectedAsset) {
      selectedAsset = asset;
    }
    return {
      change: get(selectedAsset, 'native.change', '-'),
      changeDirection: get(selectedAsset, 'price.relative_change_24h', 0) > 0,
      selectedAsset,
    };
  }),
  withHandlers({
    onOpen: ({ setIsOpen }) => () => {
github rainbow-me / rainbow / src / components / expanded-state / TokenExpandedState.js View on Github external
icon="send"
        label="Send to..."
        onPress={onPressSend}
      />
    
  
);

TokenExpandedState.propTypes = {
  onPressSend: PropTypes.func,
  price: PropTypes.string,
  subtitle: PropTypes.string,
  title: PropTypes.string,
};

export default compose(
  withAccountData,
  withAccountSettings,
  withProps(({
    asset: {
      address,
      name,
      symbol,
      ...asset
    },
    assets,
    nativeCurrencySymbol,
  }) => {
    const selectedAsset = ethereumUtils.getAsset(assets, address);
    return {
      price: get(selectedAsset, 'native.price.display', null),
      subtitle: get(selectedAsset, 'balance.display', symbol),
github rainbow-me / rainbow / src / components / token-family / TokenFamilyWrap.js View on Github external
TokenFamilyWrap.getHeight = getHeight;

const familyIdSelector = state => state.familyId;
const openFamilyTabsSelector = state => state.openFamilyTabs;

const isFamilyOpenSelector = (familyId, openFamilyTabs) => ({
  isFamilyOpen: openFamilyTabs && openFamilyTabs[familyId],
});

const withFamilyOpenStateProps = createSelector(
  [familyIdSelector, openFamilyTabsSelector],
  isFamilyOpenSelector,
);

export default compose(
  withSafeTimeout,
  withFabSendAction,
  withOpenFamilyTabs,
  withProps(withFamilyOpenStateProps),
  withState('areChildrenVisible', 'setAreChildrenVisible', false),
  withHandlers({
    onHideChildren: ({ areChildrenVisible, setAreChildrenVisible }) => () => {
      if (areChildrenVisible) {
        setAreChildrenVisible(false);
      }
    },
    onPressFamilyHeader: ({ familyId, isFamilyOpen, setOpenFamilyTabs }) => () => (
      setOpenFamilyTabs({
        index: familyId,
        state: !isFamilyOpen,
      })
github rainbow-me / rainbow / src / hoc / withUniqueTokens.js View on Github external
export default Component =>
  compose(
    connect(mapStateToProps),
    withProps(sendableUniqueTokens)
  )(Component);
github rainbow-me / rainbow / src / hoc / withWalletConnectConnections.js View on Github external
export default Component =>
  compose(
    connect(mapStateToProps, {
      walletConnectClearTimestamp,
      walletConnectDisconnectAllByDappName,
      walletConnectUpdateTimestamp,
    }),
    withProps(walletConnectSelector)
  )(Component);
github rainbow-me / rainbow / src / hoc / withAccountTransactions.js View on Github external
export default Component => compose(
  connect(mapStateToProps),
  withProps(transactionsCountSelector),
)(Component);
github rainbow-me / rainbow / src / hoc / withAccountAssets.js View on Github external
export default Component => compose(
  connect(mapStateToProps),
  withProps(sortAssets),
)(Component);
github rainbow-me / rainbow / src / hoc / withAccountSettings.js View on Github external
export default Component =>
  compose(
    connect(
      mapStateToProps,
      {
        settingsChangeLanguage,
        settingsChangeNativeCurrency,
      }
    ),
    withProps(withLanguageSelector),
    withProps(withNativeCurrencySelector)
  )(Component);

recompact

A set of React high order components based on Rx.

MIT
Latest version published 6 years ago

Package Health Score

45 / 100
Full package analysis