# Obtain a list of user channels from the useSendbirdStateContext hook

**URL:** <https://community.sendbird.com/t/obtain-a-list-of-user-channels-from-the-usesendbirdstatecontext-hook/2641>\
**Category:** JavaScript\
**Tags:** react-js\
**Created:** [July 14, 2021, 8:29am UTC](https://community.sendbird.com/t/obtain-a-list-of-user-channels-from-the-usesendbirdstatecontext-hook/2641 "2021-07-14T08:29:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toni\_U](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/toni_u/32/1040_2.png) [@Toni\_U](https://community.sendbird.com/u/Toni_U)\
**Post date:** [July 14, 2021, 8:29am UTC](https://community.sendbird.com/t/obtain-a-list-of-user-channels-from-the-usesendbirdstatecontext-hook/2641/1 "2021-07-14T08:29:04Z")

</div>

Hello,  
In a component nested inside a `<SendbirdProvider>...</>` I’m using the hook to access the senbird instance.  
I would like to obtain a list of all the user’s channels (and their url’s) via hook, how can I do that?

```javascript

// Note this component is nested inside the provider
const UserChannels = () =>{
 const state = useSendbirdStateContext();
 console.log("my state context", state)

 return (
   <div>hello</div>
 )
}

```

I do obtain the following object containing the `sdk` instances and the `user` store but it’s not obvious which selector (or which nested field?) I should use to get the list of GroupChannels of the currentUser.

```javascript
{
config: {...}.
stores: { sdkStore: {...}, userStore: {}}
}

```

How can I extrat the list of group channels for the current user via hook?

Thanks

---

<div class="post-metadata">

**Author:** ![Charis\_Theodoulou](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/charis_theodoulou/32/1401_2.png) [@Charis\_Theodoulou](https://community.sendbird.com/u/Charis_Theodoulou)\
**Post date:** [July 26, 2021, 9:06am UTC](https://community.sendbird.com/t/obtain-a-list-of-user-channels-from-the-usesendbirdstatecontext-hook/2641/2 "2021-07-26T09:06:50Z")

</div>

Hi @Toni_U

One way you can do this is to use the state context to get Sendbird selectors back, which can then be used to create a [`GroupChannelListQuery`](https://sendbird.github.io/core-sdk-javascript/module-model_query_groupChannelListQuery-GroupChannelListQuery.html) like in this example:

```javascript
import React, { useEffect, useState } from 'react'
import { sendBirdSelectors, useSendbirdStateContext } from 'sendbird-uikit';

const Component = () => {
  const context = useSendbirdStateContext()
  const sdkInstance = sendBirdSelectors.getSdk(context)
  const [groupChannels, setGroupChannels] = useState(null)

  useEffect(() => {
    if (sdkInstance && sdkInstance.GroupChannel) {
      const query = sdkInstance.GroupChannel.createMyGroupChannelListQuery()
      query.includeEmpty = true;
      query.next((_groupChannels, error) => {
        if (error) {
          console.error("GroupChannelListQuery Error: ", error)
          return
        }
        setGroupChannels(_groupChannels)
      })
    }
  }, [sdkInstance])

// ...

```

Finally you should be able to map through `groupChannels` variable in the state above and access the `url` property.  
([More general information in the docs](https://sendbird.com/docs/chat/v3/javascript/guides/group-channel#2-retrieve-a-list-of-channels) about retrieving a group channels list)

Hopefully this helps,  
Charis
