Skip to content

Commit

Permalink
When React.Strict is used, polling does not automatically start when …
Browse files Browse the repository at this point in the history
…a pollInterval is specified, startPolling must be explicitly called (#433)
  • Loading branch information
justinlampley authored Dec 7, 2022
1 parent 354f73f commit bef3430
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/ui/components/SerialConnectionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ const SerialConnectionForm: FunctionComponent<SerialConnectionFormProps> = (
) => {
const { onConnect, serialDevice, baudRate } = props;

const { loading, data, error, previousData } = useAvailableDevicesListQuery({
pollInterval: 1000,
});
const { loading, data, error, previousData, startPolling, stopPolling } =
useAvailableDevicesListQuery();

useEffect(() => {
startPolling(1000);
return () => {
stopPolling();
};
}, [startPolling, stopPolling]);

const options: Option[] =
data?.availableDevicesList?.map((target) => ({
label: `${target.path} ${target.manufacturer}`,
Expand Down
13 changes: 10 additions & 3 deletions src/ui/components/SerialDeviceSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ const SerialDeviceSelect: FunctionComponent<SerialDeviceSelectProps> = (
) => {
const { serialDevice, onChange } = props;

const { loading, data, error, previousData } = useAvailableDevicesListQuery({
pollInterval: 1000,
});
const { loading, data, error, previousData, startPolling, stopPolling } =
useAvailableDevicesListQuery();

useEffect(() => {
startPolling(1000);
return () => {
stopPolling();
};
}, [startPolling, stopPolling]);

const options: Option[] =
data?.availableDevicesList?.map((target) => ({
label: `${target.path} ${target.manufacturer}`,
Expand Down

0 comments on commit bef3430

Please sign in to comment.