Coder Social home page Coder Social logo

Comments (9)

RuslanLeafio avatar RuslanLeafio commented on June 1, 2024 5

the same issue
react-native 0.72.4

from why-did-you-render.

sebastien-f avatar sebastien-f commented on June 1, 2024 1

for what that's worth, I have the same setup as you and getting logs. The only difference is that I migrated to :

import React from 'react';

if (___DEV___) {
  const whyDidYouRender = require('@welldone-software/why-did-you-render')
  whyDidYouRender(React, {
    trackAllPureComponents: true,
  })
}`

Before that, I had it deactivated for a while and refactored quite a lot of components and screens. When reactivated, I was having no logs, then tried that.

I'm now getting a log once in a while, not sure if my code improved THAT much everything or if something changed in React/RN that makes WDYR triggers less.

from why-did-you-render.

sergeylaptev avatar sergeylaptev commented on June 1, 2024

I’ve described the solution for react-native projects in this pull request #288

from why-did-you-render.

avisek123 avatar avisek123 commented on June 1, 2024

Hi @sergeylaptev I've followed the steps but still getting no logs .

babel.config.js

module.exports = {
  presets: ['module:@react-native/babel-preset'],

  env: {
    development: {
      plugins: [['@babel/plugin-transform-react-jsx', {runtime: 'classic'}]],
    },
  },
};

wdyr.ts

/// <reference types="@welldone-software/why-did-you-render" />
import React from 'react';

if (process.env.NODE_ENV === 'development') {
  const whyDidYouRender = require('@welldone-software/why-did-you-render');
  whyDidYouRender(React, {
    trackAllPureComponents: true,
    logOnDifferentValues: true,
    collapseGroups: true,
    trackHooks: true,
  });
}

App.tsx


import {Button, Text, View} from 'react-native';
import React, {useState} from 'react';

const App = () => {
  const [count, setCount] = useState(0);

  return (
    <View>
      <Text>{count}</Text>
      <ChildComponent />

      <Button title="Increment" onPress={() => setCount(count + 1)} />
    </View>
  );
};

const ChildComponent = React.memo(({data}: any) => {
  return (
    <View>
      <Text>{data}</Text>
    </View>
  );
});
ChildComponent.whyDidYouRender = true;

export default App;

index.js

import './wdyr';
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

from why-did-you-render.

SudoPlz avatar SudoPlz commented on June 1, 2024

try collapseGroups: false in settings

from why-did-you-render.

avisek123 avatar avisek123 commented on June 1, 2024

@SudoPlz I have tried this also but not working .
Please help here . @sergeylaptev @SudoPlz

from why-did-you-render.

SudoPlz avatar SudoPlz commented on June 1, 2024

@avisek123 I'm not sure why it's not working, I'm also just experimenting myself. I had luck with both that flag, and include: [/^.*YourComponentName$/],

from why-did-you-render.

davoam avatar davoam commented on June 1, 2024

The same issue. It's not working. Tried with react-native version 0.73.4, tried setting include and collapseGroups: false

from why-did-you-render.

pooriamo avatar pooriamo commented on June 1, 2024

I'm using react native 0.73.4 and my babel.config.js is is using module:@react-native/babel-preset.

And I don't have logs.

@sergeylaptev

from why-did-you-render.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.