0.1.9 • Published 5 years ago

@pdeona/react-control-flow v0.1.9

Weekly downloads
10
License
MIT
Repository
github
Last release
5 years ago

React Control Flow CircleCI

If

import React from 'react';
import { If } from '@pdeona/react-control-flow';

export const HomePage = ({ user }) => (
  <If cond={!!user}>
    <UserDashboard user={user}>
  </If>
);

Else

import React from 'react';
import { Else, If } from '@pdeona/react-control-flow';

export const HomePage = ({ user }) => (
  <If cond={!!user}>
    <UserDashboard user={user}>
    <Else>
      <SignUpForm />
    </Else>
  </If>
);

ElseIf

import React from 'react';
import { Else, ElseIf, If } from '@pdeona/react-control-flow';

export const HomePage = ({ signUpEmail, user }) => (
  <If cond={!!user}>
    <UserDashboard user={user}>
    <ElseIf cond={!!signUpEmail}>
      <EmailVerificationModal email={signUpEmail}>
    </ElseIf>
    <Else>
      <SignUpForm />
    </Else>
  </If>
);

For

import React from 'react';
import { For } from '@pdeona/react-control-flow';

const UserListItem = ({ user }) => (
  <div>
    <span>User id: {user.uid}</span>
    <span>User name: {user.name}</span>
  </div>
);

export const UsersIndex = ({ users }) => (
  <For let="user" of={users} Render={UserListItem}>
);

Switch

import React from 'react';
import { Switch } from '@pdeona/react-control-flow';

const Router = ({ pathname }) => (
  <Switch of={pathname}>
    <AccountPage case="/account" />
    <StorePage case="/store" />
    <HomePage default />
  </Switch>
)
0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago