question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to get it work on Expo

See original GitHub issue

Hi, 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

1reaction
vzaidmancommented, Sep 10, 2019

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 😃

0reactions
vzaidmancommented, Aug 8, 2021

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found