-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathvolumeComponentWrapper.js
More file actions
23 lines (22 loc) · 1016 Bytes
/
volumeComponentWrapper.js
File metadata and controls
23 lines (22 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import VolumeComponent from "./volumeComponent";
import { useRecoilState } from "recoil";
import volumeAtom from "../../Recoil/volumeAtom";
import React from "react";
/**
* Wrapper functional component for VolumeComponent class
* Allows VolumeComponent to access and modify the state of volumeAtom
* Necessary because useRecoilState() (a hook) cannot be called inside a class component
* @param props.groupId {string} Used to target specific group when fetching current group volume from Sonos API
* @param props.museClientConfig {JSON} Contains access token for Sonos API call
* @returns {JSX.Element} VolumeComponent
*/
export default function VolumeComponentWrapper(props) {
// volumeState accesses the state of volumeAtom, setVolumeAtom modifies the state of volumeAtom
const [volumeState, setVolumeState] = useRecoilState(volumeAtom);
return (<VolumeComponent
groupId={props.groupId}
museClientConfig={props.museClientConfig}
state={volumeState}
setState={setVolumeState}
/>);
}