Resource actions

useSetData

Hook that returns resource setData action. Accepts namespace string redux data key.

useSetData(namespace:string)
import { useSetData } from '@cranium/resource'
function MyReactComponent () {
const setData = useSetData('cars')
return <button onClick={()=>setData(null)}>clear data</button>
}

useSetErrors

Hook that returns resource setErrors action. Accepts namespace string redux data key.

useSetErrors(namespace:string)
import { useSetErrors } from '@cranium/resource'
function MyReactComponent () {
const setErrors = useSetErrors('cats')
return <button onClick={()=>setErrors(null)}>clear errors</button>
}

useSetFilters

Hook that returns resource setFilters action. Accepts namespace string redux data key.

useSetFilters(namespace:string)
import { useSetFilters } from '@cranium/resource'
function MyReactComponent () {
const setFilters = useSetFilters('reports')
return <button onClick={()=>setFilters({ offset: 2 })}>set filters</button>
}

useSetLoading

Hook that returns resource setLoading action. Accepts namespace string redux data key.

useSetLoading(namespace:string)
import { useSetLoading } from '@cranium/resource'
function MyReactComponent () {
const setLoading = useSetLoading('cars')
return <button onClick={()=>setLoading(true)}>toggle loading</button>
}