DEV Community

Mahmoud Elmahdi
Mahmoud Elmahdi

Posted on

React Utility Components

Reusable react components to maximize your coding efficiency.

Install

npm i @melmahdi/reactuc
Enter fullscreen mode Exit fullscreen mode

Components

  • If
  • Image
  • Iterate
  • Table

Usage

If

Conditional rendering component

import { If } from "@melmahdi/reactuc";

<If condition={condition: 1 | 0} otherwise={otherwise: ReactNode}>
  ...
</If>
Enter fullscreen mode Exit fullscreen mode

Image

Component to handle broken images

import { Image } from "@melmahdi/reactuc";

<Image fallback={...} src="..." alt="..." />
Enter fullscreen mode Exit fullscreen mode

Iterate

Component to handle iterations.

Display list of paragraph (with html tag):

import { Iterate } from '@melmahdi/reactuc';

<Iterate data={['...', '...', '...']} element="p" />;
Enter fullscreen mode Exit fullscreen mode

Display list of objects (with component):

import { Iterate } from "@melmahdi/reactuc";

const cards = [
  { id: '75ebc192', title: 'Lira Fresh Optimization' },
  ...
];

<Iterate data={users} element={UserComponent} />;
Enter fullscreen mode Exit fullscreen mode

Table

Table component

import { Table } from "@melmahdi/reactuc";

const tableData = {
  head: ['First', <button type="button">Action</button>],
  body: [
    ['One', 'Two'],
    ...,
  ]
};

<Table {...data} />
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay