Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No logs or anything about WDYR #280

Open
JamesDev21 opened this issue Sep 8, 2023 · 9 comments
Open

No logs or anything about WDYR #280

JamesDev21 opened this issue Sep 8, 2023 · 9 comments

Comments

@JamesDev21
Copy link

JamesDev21 commented Sep 8, 2023

I follewed the setup instructions but I see no logs or anything. I am using CRA v5.0.1 and the react version is 18.2. WDYR is v7.0.1. Is this a compatibility issues? thanks

index.js:

import './whyDidYouRender'

import React from 'react'
import ReactDOM from 'react-dom/client'

// GLOBAL STYLES
import 'styles/global.module.scss'

// CONTEXT
import { AppProvider } from 'context/AppContext'

import App from './App'

const root = ReactDOM.createRoot(document.getElementById('root'))

root.render(
  <AppProvider>
    <App />
  </AppProvider>
)


whyDidYouRender.js:

import React from 'react';

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

the same issue
react-native 0.72.4

@sebastien-f
Copy link

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.

@sergeylaptev
Copy link
Contributor

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

@avisek123
Copy link

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);

@SudoPlz
Copy link

SudoPlz commented Mar 14, 2024

try collapseGroups: false in settings

@avisek123
Copy link

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

@SudoPlz
Copy link

SudoPlz commented Mar 14, 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$/],

@davoam
Copy link

davoam commented Apr 17, 2024

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

@pooriamo
Copy link

pooriamo commented May 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants