Using styled-components with props and TypeScript

There have been some recent developments and with a new version of Typescript (eg. 3.0.1) and styled-components (eg. 3.4.5) there’s no need for a separate helper. You can specify the interface/type of your props to styled-components directly. interface Props { onPress: any; src: any; width: string; height: string; } const Icon = styled.Image<Props>` width: ${p … Read more

How to get simple dispatch from this.props using connect w/ Redux?

By default mapDispatchToProps is just dispatch => ({ dispatch }). So if you don’t specify the second argument to connect(), you’ll get dispatch injected as a prop in your component. If you pass a custom function to mapDispatchToProps, you can do anything with the function. A few examples: // inject onClick function mapDispatchToProps(dispatch) { return … Read more

Preset files are not allowed to export objects

You’re using a combination of Babel 6 and Babel 7. There is no guarantee of compatibility across versions: “@babel/core”: “^7.0.0-beta.40”, “babel-cli”: “^6.26.0”, “babel-loader”: “^8.0.0-beta.0”, “babel-plugin-lodash”: “^3.3.2”, “babel-plugin-react-transform”: “^3.0.0”, “babel-preset-react”: “^6.24.1”, should be “@babel/core”: “^7.0.0-beta.40”, “@babel/cli”: “^7.0.0-beta.40”, “babel-loader”: “^8.0.0-beta.0”, “babel-plugin-lodash”: “^3.3.2”, “babel-plugin-react-transform”: “^3.0.0”, “@babel/preset-react”: “^7.0.0-beta.40”, and query: { presets: [‘react’, ‘es2015’], plugins: [‘transform-class-properties’] } would be … Read more

Typescript + React/Redux: Property “XXX” does not exist on type ‘IntrinsicAttributes & IntrinsicClassAttributes

So after reading through some related answers (specifically this one and this one and looking at @basarat’s answer to the question, I managed to find something that works for me. It looks (to my relatively new React eyes) like Connect was not supplying an explicit interface to the container component, so it was confused by … Read more