From 1d385372634e3665376aca6b2c028f504472daf0 Mon Sep 17 00:00:00 2001 From: Owen Pearson Date: Thu, 21 Sep 2023 15:40:54 +0100 Subject: [PATCH] docs: add array -> object hook return values to react migration guide --- docs/react-migration-guide.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/react-migration-guide.md b/docs/react-migration-guide.md index 2209e624d0..156f2158b5 100644 --- a/docs/react-migration-guide.md +++ b/docs/react-migration-guide.md @@ -2,6 +2,18 @@ ## Version 2.x to 3.x +### Hooks now return object + +In previous versions of our react hooks, the `useChannel` and `usePresence` hooks returned arrays. +Since these hooks now return more values we've opted to change them to return objects. +You can still access the return values using simple destructuring syntax like in the below example: + +```jsx +const { channel, ably } = useChannel("your-channel-name", (message) => { /* ... */ }); + +const { presenceData, updateStatus } = usePresence("your-channel-name"); +``` + ### Replacing `configureAbly` with `AblyProvider` In versions 1 and 2 of our react-hooks, we exported a function called `configureAbly` which was used to register an Ably client instance to global state.