- #98: Return type of
submit()
function is changed fromvoid
toPromise<void>
@BeckyPollard - #95:
loading
did not go back totrue
if an error occurred in some cases.
- #94: Complete rewrite of
useInfiniteCollection
it had still more issues in edge-cases, so it needed a higher-approach to fixing it.
Note: a bunch of versions were skipped. They were all released as beta to test issues with this hook.
- #93: Reverted fix from for
useInfiniteCollection
, which had another negative side-effect. Both the side-effect and the original issue should be fixed with this release.
- #90
useInfiniteCollection
did not refresh correctly with if there was only 1 page.
- #87
useInfiniteCollection
'srefreshOnStale
did not function correctly. it now fully resets the component.
- Same as the last beta.
useNewResource
now assumes HAL as the default format.
- Added
<SelectLink>
component. This component renders a<select>
element with a list of links from a resource. - Added
useNewResource
, which lets you create new resources on collections using aPOST
request. - Several optimizations, reducing renders for
useResource
from 5 down to 2 in certain cases. react-ketting
now re-exports everything from theketting
package.- BC Break:
mode
option fromuseResource
has been removed. - Fixed an infinite rendering bug when passing a promise to
useResource
.
- Fix Ketting dependency version.
- #75:
usePagedCollection
is renamed touseInfiniteCollection
. The old function name will continue to work until the next major version, but you are encouraged to rename all uses of it. - #76 #61:
useCollection()
now returns the sameitems
array every call. This can help avoid re-renders and potentially even render loops.
useCollection
now returns 'resourceState' and 'resource', which makes it less likely that someone needs bothuseResource
anduseCollection
in the same component. These objects were already readily available, so might as well return them.
- BC Break: The signature of
useResource
has changed, but only if you were passing options. If you calleduseResource(options)
before, it must now be structured asuseResource(resource, options)
to be consistent with every other hook. - In some cases when a React component passes a new resource as a string to useResource, the useResource might return "undefined" for the resource, which can result in a white screen of death. This one was a bit of a doozy, check the PR for more information: #67
- Remove an unneeded initial render in
useCollection
.
- In some cases when a React component passes a new resource as a string to useResource, the useResource might return "undefined" for the resource, which can result in a white screen of death. See PR #67 #70
- In some scenarios
RequireLogin
could crash due to a function sometimes being called before it's defined (@mihok). - Works with Typescript 4.4 strict.
usePagedCollection
did not behave correctly with pages or collections that were already cached. Now it doesn't care if the page was cached or not.
- In
usePagedCollection
, when the resource property changes, the first pag was not reloaded, resulting in an empty collection.
- If
usePagedCollection
was given a promise, it would go in an infinite render loop.
- Added
usePagedCollection
, which allows users to create 'infinite scroll' interfaces. - Some heavy duty refactoring to encourage better re-use of internal hooks.
- Stable release
- No functional changes since 2.0.0-beta.0
- Compatibility with Ketting 7.
UseResourceOptions
is now exported
- #43: Remove incorrect 'browser' property from
package.json
. This should never have been there and was causing issues for some build systems.
- Correctly handle 'invalid_grant' errors from an OAuth2 server.
useResolveResource
is now exported.
- Add
refreshOnStale
option touseResource
.
- The 'type' of the result of useCollection is not dependent on the 'type'
of the collection that was passed it. This was a bug in
useCollection
.
- Update ketting and fetch-mw-oauth2
- expireAt for oauth2 token is now preserved via LocalStorage.
- Add 'refreshOnStale' option to
useCollection
, to automatically fetch new items if the collection is known to have changed.
- Refresh "items" in
useCollection
if the resource argument changed.
- Cleanup bug in
useResource
hook.
- Fixing another bug related to prop changes / effects / dependencies in useEffect.
- Make sure
data
andresourceState
get re-fetched when the resource arg changes in theuseResource
hook.
- Guarantee re-render on when
setData()
orsetResourceState()
is used.
- Fix an issue with RequireLogin trying to validate a 'code' twice.
- RequireLogin should be a bi snappier with fewer async ops.
- Fewer renders and much faster first render if there's a cached state with
useResource
. - Handle expired Access / Refresh tokens better. We now send the user back into the authentication process.
- Added the ability to override the endpoint
RequireLogin
uses to test if the Bearer token is correct.
- Added a
useCollection
hook, for easily traversing a collection of resources. - The
useResource
hook now also emits the 'real' resource that was used.
- Added a
RequireLogin
component. If you're using the OAuth2authorization_code
flow, this component can do most of the work to set this up, and set the correct access/refresh tokens in Ketting. It uses LocalStorage to save the tokens. (@simistern) - Fix a bug related to
useResource
andsetData
.
- Ketting 6 got a stable release, so this package gets a 1.0 release as well.
useResource
can now take a Promise that resolves to a resource from its first argument.ResourceLike
is now exported.
useResource()
can now take a URI argument instead of a Resource object.useResource()
can also take a Promise that resolves to a resource.- Added a
KettingProvider
component, giving any component access to the closest Ketting client viauseContext
/contextType
. - Added a
useClient
hook to easily find the Client object in functional components.
- Rewrite of
useResource
. It can now fully manage updating state, submitting to the server. - 'New resource' flow in useResource, allowing it be be used to create a new
resource via
POST
request, and subsequentPUT
requests. - A simpler
useReadResource
hook. Providing read-only access to resources, and change subscriptions.
useResource
now also returnsupdateResourceState
andupdateData
functions, to easily store state changes in a local cache.useResource
hook will avoid emitting state changes after a component is cleaned up.
ketting
is now a peerDepedency.- Updated dependencies.
- Updated to latest Ketting 6 alpha.
- Both the hook and HoC listen for the
update
event and automatically re-render when they are triggered. - The
state
property in the useResource hook is renamed toresourceState
for consistency with the HoC. - All
body
properties are renamed todata
.
- Added a
withResource
HoC for class-based React Components.
- Remove race condition.
- Remove webpack. Lets assume for now people have their own build pipeline.
- Simplify result from
useResource
.
- useResource now returns an object with
loading
,error
,body
andstate
properties.
- First version!