1.2.5 • Published 2 years ago

for-util v1.2.5

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

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 } 
1.2.0

2 years ago

1.1.0

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.0.5

2 years ago

1.2.2

2 years ago

1.0.2

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago