Skip to content

Commit

Permalink
Fixes all ts errors, hopefully :P
Browse files Browse the repository at this point in the history
  • Loading branch information
ankeetmaini committed Jan 21, 2020
1 parent 4b2f897 commit 87c88b0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/components/NetworkProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ function NetworkProvider({
pingServerUrl = DEFAULT_ARGS.pingServerUrl,
pingTimeout = DEFAULT_ARGS.pingTimeout,
shouldPing = DEFAULT_ARGS.shouldPing,
...rest
}: Props) {
const { children } = rest;
children,
}: Partial<Props>) {
return (
<NetworkConnectivity {...rest}>
<NetworkConnectivity
{...{
httpMethod,
pingInBackground,
pingInterval,
pingOnlyIfOffline,
pingServerUrl,
pingTimeout,
shouldPing,
}}
>
{connectionState => (
<NetworkContext.Provider value={connectionState}>
{children}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReduxNetworkProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class ReduxNetworkProvider extends React.Component<Props> {
}
}

const mapStateToProps = (state: AppState, _?: OwnProps) => ({
isConnected: !!state.network.isConnected,
const mapStateToProps = (state: AppState) => ({
isConnected: state.network.isConnected,
});

const ConnectedReduxNetworkProvider = connect(mapStateToProps)(
Expand Down
5 changes: 4 additions & 1 deletion test/ReduxNetworkProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
mapStateToProps,
} from '../src/components/ReduxNetworkProvider';
import { connectionChange } from '../src/redux/actionCreators';
import { NetworkState } from '../src/types';

const dispatch = jest.fn();
const props = {
Expand Down Expand Up @@ -69,8 +70,10 @@ describe('ReduxNetworkProvider', () => {

describe('mapStateToProps', () => {
it('maps isConnected and actionQueue state to props', () => {
const networkState = {
const networkState: NetworkState = {
isConnected: false,
actionQueue: [],
isQueuePaused: false,
};
const state = {
network: networkState,
Expand Down

0 comments on commit 87c88b0

Please sign in to comment.