Skip to content

Commit e0532ae

Browse files
committedDec 23, 2019
Added eslint disable - Fixed #197
1 parent b8d7abe commit e0532ae

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed
 

‎README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,6 @@ interface InjectedProps {
719719
export const withConnectedCount = <BaseProps extends InjectedProps>(
720720
BaseComponent: React.ComponentType<BaseProps>
721721
) => {
722-
type HocProps = Diff<BaseProps, InjectedProps> & {
723-
// here you can extend hoc with new props
724-
initialCount?: number;
725-
};
726-
727722
const mapStateToProps = (state: RootState) => ({
728723
count: countersSelectors.getReduxCounter(state.counters),
729724
});
@@ -732,18 +727,24 @@ export const withConnectedCount = <BaseProps extends InjectedProps>(
732727
onIncrement: countersActions.increment,
733728
};
734729

735-
class Hoc extends React.Component<InjectedProps> {
730+
type HocProps = ReturnType<typeof mapStateToProps> &
731+
typeof dispatchProps & {
732+
// here you can extend ConnectedHoc with new props
733+
overrideCount?: number;
734+
};
735+
736+
class Hoc extends React.Component<HocProps> {
736737
// Enhance component name for debugging and React-Dev-Tools
737738
static displayName = `withConnectedCount(${BaseComponent.name})`;
738739
// reference to original wrapped component
739740
static readonly WrappedComponent = BaseComponent;
740741

741742
render() {
742-
const { count, onIncrement, ...restProps } = this.props;
743+
const { count, onIncrement, overrideCount, ...restProps } = this.props;
743744

744745
return (
745746
<BaseComponent
746-
count={count} // injected
747+
count={overrideCount || count} // injected
747748
onIncrement={onIncrement} // injected
748749
{...(restProps as BaseProps)}
749750
/>
@@ -754,7 +755,7 @@ export const withConnectedCount = <BaseProps extends InjectedProps>(
754755
const ConnectedHoc = connect<
755756
ReturnType<typeof mapStateToProps>,
756757
typeof dispatchProps, // use "undefined" if NOT using dispatchProps
757-
HocProps,
758+
Diff<BaseProps, InjectedProps>,
758759
RootState
759760
>(
760761
mapStateToProps,
@@ -776,7 +777,7 @@ import { FCCounter } from '../components';
776777
const FCCounterWithConnectedCount = withConnectedCount(FCCounter);
777778

778779
export default () => (
779-
<FCCounterWithConnectedCount initialCount={5} label={'FCCounterWithState'} />
780+
<FCCounterWithConnectedCount overrideCount={5} label={'FCCounterWithState'} />
780781
);
781782

782783
```
@@ -1262,6 +1263,7 @@ export default store;
12621263
A solution below is using a simple factory function to automate the creation of type-safe action creators. The goal is to decrease maintenance effort and reduce code repetition of type annotations for actions and creators. The result is completely typesafe action-creators and their actions.
12631264
12641265
```tsx
1266+
/* eslint-disable */
12651267
import { action } from 'typesafe-actions';
12661268

12671269
import { ADD, INCREMENT } from './constants';

‎playground/src/features/counters/actions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable */
12
import { action } from 'typesafe-actions';
23

34
import { ADD, INCREMENT } from './constants';

0 commit comments

Comments
 (0)
Failed to load comments.