Trying to use @babel/plugin-proposal-class-properties
.
- https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-class-properties
- https://github.com/oblador/react-native-animatable#user-content-attention-seekers
- https://www.npmjs.com/package/react-native-animatable
A
Yields this error
Failed to compile.
./node_modules/react-native-animatable/createAnimatableComponent.js
SyntaxError: /Users/timothyw/Projects/beatthemarket/beatthemarket.reactnative-paper/beatthemarket.frontend/node_modules/react-native-animatable/createAnimatableComponent.js: Support for the experimental syntax 'classProperties' isn't currently enabled (133:24):
131 |
132 | return class AnimatableComponent extends Component {
> 133 | static displayName = `withAnimatable(${wrappedComponentName})`;
| ^
134 |
135 | static propTypes = {
136 | animation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
B
Installation and code look like this.
sh
yarn add @babel/plugin-proposal-class-properties --dev
MyComponent.js
...
<Animatable.View
animation="pulse"
easing="ease-out"
iterationCount="infinite">
<SocialButton
onPress={signInWithGoogle}
imageSource={IMAGES.GOOGLE}
style={{
container: themedStyles.googleIconContainer,
image: themedStyles.googleIcon,
}}
/>
</Animatable.View>
...
babel.config.js
module.exports = {
presets: [ "module:metro-react-native-babel-preset", "@babel/preset-env", "@babel/preset-react" ],
plugins: [ ["@babel/plugin-proposal-class-properties", {"loose": true}] ],
}
C
And these SO notes don't seem to help.