Skip to content

Commit

Permalink
updated react hook usage for network and battery
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-karlovskiy committed Aug 15, 2019
1 parent c363c1e commit 76eca4b
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useBatteryStatus } from '../../utils/hooks';
import './battery-considerate-media.css';

const BatteryConsiderateMedia = () => {
const batteryStatus = useBatteryStatus();
if (!batteryStatus) return <Fragment>Loading...</Fragment>;
const { batteryStatus } = useBatteryStatus();
if (!batteryStatus) return <Fragment>Loading...</Fragment>;

console.log('[BatteryConsiderateMedia] batteryStatus, batteryStatus.unsupportMessage => ', batteryStatus, batteryStatus.unsupportMessage);

Expand Down
2 changes: 1 addition & 1 deletion cra-battery-considerate-loading/src/utils/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const useBatteryStatus = () => {
// eslint-disable-next-line
}, []);

return batteryStatus;
return { batteryStatus, updateBatteryStatus };
};

export { useBatteryStatus };
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useEffectiveConnectionType } from '../../utils/hooks';
import './connection-aware-media.css';

const ConnectionAwareMedia = () => {
const effectiveConnectionType = useEffectiveConnectionType();
const { effectiveConnectionType } = useEffectiveConnectionType();

console.log('[ConnectionAwareMedia] effectiveConnectionType => ', effectiveConnectionType);

Expand Down
2 changes: 1 addition & 1 deletion cra-network-aware-component/src/utils/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const useEffectiveConnectionType = () => {
// eslint-disable-next-line
}, []);

return effectiveConnectionType;
return { effectiveConnectionType, updateECTStatus };
};

export { useEffectiveConnectionType };
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useEffectiveConnectionType } from '../../utils/hooks';
const IFixitSearch = () => {
const [loading, setLoading] = useState(false);
const [searchResults, setSearchResults] = useState([]);
const effectiveConnectionType = useEffectiveConnectionType();
const { effectiveConnectionType } = useEffectiveConnectionType();
let searchLimit;
switch (effectiveConnectionType) {
// case 'offline':
Expand Down
2 changes: 1 addition & 1 deletion cra-network-aware-data-fetching/src/utils/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const useEffectiveConnectionType = () => {
// eslint-disable-next-line
}, []);

return effectiveConnectionType;
return { effectiveConnectionType, updateECTStatus };
};

export { useEffectiveConnectionType };
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useEffectiveConnectionType } from '../../../utils/hooks';
import { IMAGE_BASE_URL, POSTER_SIZES } from '../../../config';

const ConnectionAwareImage = ({ path, alt, ...rest }) => {
const effectiveConnectionType = useEffectiveConnectionType();
const { effectiveConnectionType } = useEffectiveConnectionType();

let posterSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useEffectiveConnectionType } from '../../utils/hooks';
import { IMAGE_BASE_URL, BACKDROP_SIZES } from '../../config';

const ConnectionAwareBgDiv = ({ children, backdropPath, ...rest }) => {
const effectiveConnectionType = useEffectiveConnectionType();
const { effectiveConnectionType } = useEffectiveConnectionType();

let backdropSize;
switch(effectiveConnectionType) {
Expand Down
2 changes: 1 addition & 1 deletion react-movie-network-aware-components/src/utils/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const useEffectiveConnectionType = () => {
// eslint-disable-next-line
}, []);

return effectiveConnectionType;
return { effectiveConnectionType, updateECTStatus };
};

export { useEffectiveConnectionType };

0 comments on commit 76eca4b

Please sign in to comment.