1.0.1 • Published 6 years ago

@reacthooks.org/use-classic-state v1.0.1

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
6 years ago

Install

$ npm install @reacthooks.org/use-classic-state

useClassicState

A React Hook which gives you the classic this.setState({ ... }).

(But not setState(fn).)

Synopsis

In your React component:

import { useState } from 'react'
import useClassicState from "use-classic-state"

function Skeleton() {
  const [ request, setRequest ] = useClassicState({
    loading: false,
    result: null
  })

  // then inside your Ajax request hook
  setRequest({
    loading: true,
  })

  // and once the request has returned
  setRequest({
    loading: false,
    result: { ... },
  })
}

Other Hooks

Please see all of the other reacthooks.org hooks:

Author

$ npx chilts

   ╒════════════════════════════════════════════════════╕
   │                                                    │
   │   Andrew Chilton (Personal)                        │
   │   -------------------------                        │
   │                                                    │
   │          Email : andychilton@gmail.com             │
   │            Web : https://chilts.org                │
   │        Twitter : https://twitter.com/andychilton   │
   │         GitHub : https://github.com/chilts         │
   │         GitLab : https://gitlab.org/chilts         │
   │                                                    │
   │   Apps Attic Ltd (My Company)                      │
   │   ---------------------------                      │
   │                                                    │
   │          Email : chilts@appsattic.com              │
   │            Web : https://appsattic.com             │
   │        Twitter : https://twitter.com/AppsAttic     │
   │         GitLab : https://gitlab.com/appsattic      │
   │                                                    │
   │   Node.js / npm                                    │
   │   -------------                                    │
   │                                                    │
   │        Profile : https://www.npmjs.com/~chilts     │
   │           Card : $ npx chilts                      │
   │                                                    │
   ╘════════════════════════════════════════════════════╛

(Ends)

1.0.1

6 years ago