New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-shorthand

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-shorthand

React Component library that have some conditional operations and array method as components

latest
Source
npmnpm
Version
0.2.54
Version published
Maintainers
1
Created
Source

React-Shorthand

React Component library that have some conditional operations and array method as components

Note

We really appreciate your use of our module but please put in considerations that it is still in developpement phase

NPM Registry

Components

  • If
  • IfElse
  • Switch
  • And
  • Or
  • array
    • Map
    • At
    • Find
    • Filter
    • Every
    • Some

Demo

Note

If there are 2 components grouped togther it means the two can be wroten in all the demoed methods (ex: Every/Some)

  • IfElse

    If/IfElse take same Props (key prop is for the Map method handler)

    import { IfElse } from "react-shorthand";
    
    const variable = "Hello";
    
    function App() {
      return (
        <IfElse condition={variable === "Hello"}>
          <IfElse.If>
            <p>How Are You???</p>
          </IfElse.If>
    
          <IfElse.Else>
            <p>I am Fine</p>
          </IfElse.Else>
        </IfElse>
      );
    }
    
  • array

    • At(*array, *index, Wrapper)
    • Map(*array, *Wrapper) / PS: No need to specify a key \
    • Find/Filter/Every/Some(*array, *handler)
    import { array } from "react-shorthand";
    
    function Wrapper({ item, index }) {
      return (
        <p>
          {index}.{item.item}
        </p>
      );
    }
    
    function App() {
      return (
        <array.Map
          array={[
            { _id: 1, item: "1" },
            { id: 2, item: "2" },
            { key: 3, item: "3" },
            { item: "4" },
          ]}
          Wrapper={Wrapper}
        />
      );
    }
    
    • Every/Some
    import { array } from "react-shorthand";
    
    function App() {
      return (
        <array.Every array={["1", "2"]} handler={(item) => item === "2"}>
          <array.Every.True>
            <p>Hello</p>
          </array.Every.True>
    
          <array.Every.False>
            <p>Good Bay</p>
          </array.Every.False>
        </array.Every>
      );
    }
    
    import { array } from "react-shorthand";
    
    function App() {
      return (
        <array.Some array={["1", "1"]} handler={(item) => item === "1"}>
          <p>Hello</p>
        </array.Some>
      );
    }
    
  • Switch

    import { Switch } from "react-shorthand";
    
    function App() {
      return (
        <Switch expression={"expression"}>
          <Switch.Case match="boo" children={<p>boo</p>} />
    
          <Switch.Case match="foo">
            <p>foo</p>
          </Switch.Case>
    
          <Switch.Default>
            <p>bar</p>
          </Switch.Default>
        </Switch>
      );
    }
    
  • Or/And

    And/Or take same Props

    import { Or } from "react-shorthand";
    
    function App() {
      return <Or array={[null, "foo"]} />;
    }
    
    import { And } from "react-shorthand";
    
    function App() {
      return (
        <And array={["foo", "bar"]}>
          <p>Hello</p>
        </And>
      );
    }
    

Keywords

react

FAQs

Package last updated on 16 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts