frr-util
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

Utility Functions and HOC Guard

Motivation

Just a little library that provides some useful functions and a cool data guard pattern HOC.

Install

yarn add frr-util reselect react react-redux
npm install frr-util reselect react react-redux

Guard Pattern

import { createGuard } from 'frr-util/lib/guards'

type UserGuardedProps = { user: { name: string } }

// userAsOptionSelector is selector that selects Option<{ user: { name: string } }> from the redux store
const userGuard = createGuard<UserGuardedProps>(userAsOptionSelector)

const Page = (props: UserGuardedProps) => {
  return (
    <div>
      {props.user.name}
    </div>
  )
}


const Guarded = userGuard(Page)

export { Guarded as Page } 

Readme

Keywords

none

Package Sidebar

Install

npm i frr-util

Weekly Downloads

11

Version

2.0.2

License

none

Unpacked Size

262 kB

Total Files

54

Last publish

Collaborators

  • matteogamba
  • carloszv
  • lukaszirngibl
  • joel.meiller