keshidong / react-use-that

Basic and powful react hooks
5 stars 0 forks source link

feat: add useSemantic hook #1

Closed keshidong closed 5 years ago

keshidong commented 5 years ago

To semanticize data-object type variables, add useSemantic hook to make data-object type variable's semantic consistent with its reference.

use case:

const [page, setPage] = useState({ pageCurrent: 1, pageTotal: 1 })
// The reference of page will change only when the value of pageCurrent or pageTotal changes.
const semaPage = useSemantic(page)
...