How to use react-native-realm - 2 common examples

To help you get started, we’ve selected a few react-native-realm 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 zzorba / ArkhamCards / components / withPlayerCards.tsx View on Github external
WrappedComponent: React.ComponentType,
  computeExtraProps?: (cards: Results) => ExtraProps
): React.ComponentType {
  interface ReduxProps {
    tabooSetId?: number;
  }
  const mapStateToProps = (
    state: AppState,
    props: Props & TabooSetOverride
  ): ReduxProps => {
    return {
      tabooSetId: getTabooSet(state, props.tabooSetOverride),
    };
  };
  const result = connect(mapStateToProps)(
    connectRealm(
      WrappedComponent, {
        schemas: ['Card', 'TabooSet'],
        mapToProps(
          results: CardAndTabooSetResults,
          realm: Realm,
          props: Props & ReduxProps
        ): PlayerCardProps & ExtraProps {
          const playerCards = results.cards.filtered(
            `((type_code == "investigator" AND encounter_code == null) OR deck_limit > 0 OR bonded_name != null) and ${Card.tabooSetQuery(props.tabooSetId)}`
          );
          const investigators: CardsMap = {};
          const cards: CardsMap = {};
          forEach(
            playerCards,
            card => {
              cards[card.code] = card;
github zzorba / ArkhamCards / components / weakness / withWeaknessCards.tsx View on Github external
export default function withWeaknessCards(
  WrappedComponent: React.ComponentType
): React.ComponentType {
  interface ReduxProps {
    tabooSetId?: number;
  }
  const mapStateToProps = (state: AppState): ReduxProps => {
    return {
      tabooSetId: getTabooSet(state),
    };
  };
  const result = connect(mapStateToProps)(
    connectRealm(
      WrappedComponent, {
        schemas: ['Card'],
        mapToProps(
          results: CardResults,
          realm: Realm,
          props: Props & ReduxProps
        ): WeaknessCardProps {
          const cards = results.cards
            .filtered(`${BASIC_WEAKNESS_QUERY} and ${Card.tabooSetQuery(props.tabooSetId)}`)
            .sorted([['name', false]]);
          const cardsMap: CardsMap = {};
          forEach(cards, card => {
            cardsMap[card.code] = card;
          });
          return {
            cards,

react-native-realm

A higher-order component for listening to Realm data in React Native components.

MIT
Latest version published 7 years ago

Package Health Score

39 / 100
Full package analysis

Popular react-native-realm functions