Skip to content

property does not exist on type 'IntrinsicAttributes & Pick<any, symbol>' #213

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
Rey-Wang opened this issue Jun 19, 2020 · 0 comments
Open

Comments

@Rey-Wang
Copy link

I try to integration connect with redux-thunk, and overwrite connect function like this:

import * as React from 'react'
import { connect as reactReduxConnect } from 'react-redux'
import {
  bindActionCreators,
  Dispatch,
  ActionCreatorsMapObject,
} from 'redux'

/**
 * This is just a small wrapper around react-redux's connect function
 * @param  Component                The component you want to connect
 * @param  mapStateToProps          The "normal" mapStateToProps function
 * @param  mapActionCreatorsToProps A function that returns an object with the actions your component will call
 */
export default function connect(
  Component: React.ComponentType<any>,
  mapStateToProps: (
    state: Object,
    ownProps: Object
  ) => Object,
  mapActionCreatorsToProps: (
    dispatch?: Dispatch<any>
  ) => ActionCreatorsMapObject = () => ({}) // This default value is just a function that returns an empty object
) {
  return reactReduxConnect(
    mapStateToProps,
    (dispatch: Dispatch<any>) =>
      bindActionCreators(
        mapActionCreatorsToProps(dispatch),
        dispatch
      )
  )(Component)
}

Then I use it like a usual connect

**interface IProps {
  testId: string;
  haah: number;
  getCharacters: Function;
  setCharacter: Function;
  searchCharacters: Function;
  character: any;
  characters: ICharacter[];
  isFetching: Boolean;
}

// Note: This is mainly done to enable testing
export const CharacterContainer: React.FunctionComponent<IProps> = ({
  testId,
  getCharacters,
  character,
}) => {
   //render component
};

// Make data available on props
const mapStateToProps = (store: any) => {
  return {
    character: store.characterState.character,
  };
};

// Make functions available on props
const mapDispatchToProps = (dispatch: any) => {
  return {
    getCharacters: () => dispatch(getCharactersStartActionCreator()),
  };
};

// Connect the app aware container to the store and reducersreduxConnect
export default connect(CharacterContainer, mapStateToProps, mapDispatchToProps);**

But when I use it I always get this
image

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant