Unable to get it work on Expo
See original GitHub issueHi, today im trying to work in expo and unable to get it work, something missing?
here the code:
import * as React from 'react';
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';
if (__DEV__) {
const whyDidYouRender = require('@welldone-software/why-did-you-render');
whyDidYouRender(React);
}
console.log('Example log')
export default class App extends React.Component {
static whyDidYouRender = true
constructor(props) {
super(props);
this.state = {
visible: false
};
}
render() {
const { visible } = this.state;
return (
<View style={styles.container}>
<TouchableOpacity onPress={() => this.setState({ visible: !visible })}>
<Text>{visible ? 'Hide' : 'Show'}</Text>
</TouchableOpacity>
{ visible === true && <Text style={{ marginTop: 16 }}>Hidden content</Text> }
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#ecf0f1',
padding: 8,
}
});
and here the link to snack:
https://snack.expo.io/@outatime/why-did-you-render
Thanks !!!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Unable to find expo in this project - have you run yarn / npm ...
So I run the npm command in the terminal. npm install. You do not need to change the expo version. you just reinstall...
Read more >Troubleshooting build errors and crashes - Expo Documentation
When you get the Metro encountered an error during a native iOS build, it means Metro bundler failed to bundle the app. This...
Read more >Expo Something Went Wrong : 1 Expo React Native Tip You ...
Expo Something Went Wrong : 1 Expo React Native Tip You NEED ; https://bit.ly/ttpc-monthly-access LET'S WORK You can reach me at - ;...
Read more >Troubleshooting | React Navigation
I'm getting an error "Unable to resolve module" after updating to the latest version. This might happen for 3 reasons: ... If you're...
Read more >Can't start project on expo app. Tunnel also not working - Reddit
I was getting the same error after upgrading expo. I had to switch to using npx expo start --tunnel and install the latest...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
so the library only catches re-renders that “can be prevented” like the one I planted here: https://snack.expo.io/HJKGvLBUH
how do you do this in this case? you move the array to the top and make the component pure: https://snack.expo.io/Hy-YwLHUB
but the best advice is just to build apps and never prematurely optimize.
only use whyDidYouRender for HUGE components like lists and graphics which you want to make sure are not re-rendered too many times 😃
I don’t know what “expo” is and couldn’t be able to check it out in the upcoming time as i’m in the process of moving to a new country…