2.0.2 • Published 2 years ago

frr-util v2.0.2

Weekly downloads
98
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.0.7

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.6

3 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