docs icon indicating copy to clipboard operation
docs copied to clipboard

How to use Ably with React tutorial syntax update required

Open mclark-ably opened this issue 1 year ago • 0 comments

Step 4 of the tutorial https://ably.com/tutorials/how-to-ably-react-hooks#tutorial-step-4 has the following syntax on how to use rewind

const {channel} = useChannel("[?rewind=100]your-channel-name", (message) => {
    // List the last 100 messages on the channel
    console.log(message);
});

However this does not work and the correct syntax would now be

const { channel } = useChannel({ channelName: "your-channel-name", options: { params: { rewind: '100' } } }, (message) => {
   console.log(message);
});

Which has been updated in the ably-js repo React readme https://github.com/ably/ably-js/pull/1523

┆Issue is synchronized with this Jira Task by Unito

mclark-ably avatar Jan 17 '24 15:01 mclark-ably