1.2.2 • Published 4 years ago

jsx-toolkit v1.2.2

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

jsx-toolkit

JSX-Toolkit gives you helpful components that will make your code cleaner and easier to maintain.

Jump to docs

MAP, IF

MAP Documentation

Example:

import React from 'react';
import { MAP } from 'jsx-toolkit';
import { data } from '../data';

function App() {
  return (
    <MAP el='ul' data={data}>
      {(item, i) => <li key={item.id}>{item.title}</li>}
    </MAP>
  );
}

Example with Component Library:

As you can see you can use native Material-UI props here (disablePadding & dense) and they will work, This allows you to have the same result with fewer lines of code, there is no need to wrap the MAP component with the List component since MAP becomes List thanks to the el Prop.

import React from 'react';
import { MAP } from 'jsx-toolkit';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import { data } from '../data';

function App() {
  return (
    <MAP el={List} data={data} disablePadding='true' dense>
      {(item, i) => <ListItem key={item.id}>{item.title}</ListItem>}
    </MAP>
  );
}

MAP API:

PropsTypeDefaultRequired
dataarray or object-YES
elstring or ComponentReact.FragmentNO
debugbooleanfalseNO
lenghtnumber-NO

MAP API Description

PropsDescription
dataarray or object you want to map
el<MAP el="ul"></MAP> or <MAP el={List}></MAP> default is Fragment
debugAdding the debug prop will log the data to your console and help you debugging
lenghtIf your data returns a lot of items but you need less for a preview component maybe? Then use this to shorten the data

IF Documentation

Example:

import React from 'react';
import { IF } from 'jsx-toolkit';

function App() {
  return (
    <IF
      condition={2 > 1} // condition
      isTrue={<h3>This is True :)</h3>} // return if true
      isFalse={<h3>This is false!</h3>} // else return this
    />
  );
}

IF API:

PropsTypeDefaultRequired
conditionarray or object-YES
isTrueHTML/JSX-YES
isFalseHTML/JSX-YES

IF API Description

PropsDescription
conditionDefine your condition in this prop
isTruethis gets returned if true
isFalsethis gets returned if false
1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.21

4 years ago

1.1.20

4 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.11

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago