@pdeona/react-control-flow
TypeScript icon, indicating that this package has built-in type declarations

0.1.9 • Public • Published

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>
)

Readme

Keywords

none

Package Sidebar

Install

npm i @pdeona/react-control-flow

Weekly Downloads

0

Version

0.1.9

License

MIT

Unpacked Size

11.6 kB

Total Files

14

Last publish

Collaborators

  • pdeona