babel: using passPerPreset breaks class properties with babel 6.7 (T7274)
Issue originally made by Chirag (chirag04)
Bug information
- Babel version: 6.7
- Node version: 5.6.0
- npm version: 3.6.0
Input code
{
"passPerPreset": true,
"presets": [
"react-native"
],
}
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View
} from 'react-native';
class Name extends Component {
renderName = () => {
const { name } = this.props;
return <Text>{name}</Text>
};
render() {
return this.renderName();
}
};
class aproject extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Name name={'chirag'} />
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('aproject', () => aproject);
Description
Doing a fresh install of react-native and adding .babelrc with passPerPresets breaks class properties. I get error like undefined is not an object evaluating this.props.name
.
I can confirm with works fine with babel 6.6.
PS: This is my first issue on babel repo and i’m not sure what the general guidelines are for posting an issue.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (5 by maintainers)
Commits related to this issue
- feat: option to hoist nested methods referencing `this` (`methods: true`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * https://github.com/babel/babel... — committed to motiz88/babel-plugin-transform-hoist-nested-functions by motiz88 8 years ago
- feat: option to hoist nested methods referencing `this` (`methods: true`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * https://github.com/babel/babel... — committed to motiz88/babel-plugin-transform-hoist-nested-functions by motiz88 8 years ago
- feat: option to hoist nested methods referencing `this` (`methods: true`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * https://github.com/babel/babel... — committed to motiz88/babel-plugin-transform-hoist-nested-functions by motiz88 8 years ago
- feat: option to hoist nested methods referencing `this` (`methods: true`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * https://github.com/babel/babel... — committed to motiz88/babel-plugin-transform-hoist-nested-functions by motiz88 8 years ago
- docs(babel): add option info for passPerPreset Summary: it's actually not necessary to use passPerPreset for the Relay plugin. when `passPerPreset` is true, will show error as follow on React Native... — committed to facebook/relay by yutin1987 7 years ago
BTW, for those of us hitting this issue because of Relay, it’s actually not necessary to use
passPerPreset
for the Relay plugin.@yutin1987 it’s just a warning not an error