why-did-you-render | Welldone Software monkey patches React to notify | Frontend Framework library
kandi X-RAY | why-did-you-render Summary
kandi X-RAY | why-did-you-render Summary
why-did-you-render by Welldone Software monkey patches React to notify you about potentially avoidable re-renders. (Works with React Native as well.).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Checks whether two objects are equal
- Tracks changes for a given hook .
- Tracks all dependencies to track changes .
- Prints conflicts .
- Main render function
- Creates a functional component .
- Determines whether or not the component should have changed .
- Determines if a new component was modified .
- Finds differences between the owner and the hook .
- Store the owner data to the owner .
why-did-you-render Key Features
why-did-you-render Examples and Code Snippets
Community Discussions
Trending Discussions on why-did-you-render
QUESTION
I encounter this error message when I start my react native app: Invariant Violation: "backdropFilter" is not a valid style property.
I checked that I don't have any backdropFilter
used in my source code. But I still got this error.
full error message:
...ANSWER
Answered 2021-Nov-02 at 07:31It is because backdropFilter is not one of the style props supported by react-native. You can remove it in you style sheet and the program should be able to work.
QUESTION
I'm using the why-did-you-render package to debug some performance issues in my react app. I'm getting the following console message regarding why my XDrag
component is re-rendering:
ANSWER
Answered 2021-Jul-07 at 04:57I will try to answer each question and hopefully give you some extra information to help you make a decision.
1. What exactly do they mean by a pure wrapper/ pure component? How is a pure component different from other kinds of components?In simple words, a pure component (or pure function) is a component (or function) that will always return the same output for the same input (by the way, this is not exclusive to React).
Example: function add(x, y){return x + y}
is a pure function because add(1, 2)
will always return 3
, no matter how many times you run it.
PureComponents
have the same idea. You can read more about PureComponents
in the official docs.
In the article that you linked, this is the key part to answer this question:
Always remember: the
syntax is just a sugar for:
React.createElement('jsx', {prop: 'a'})
. This means whenever it’s father re-renders, jsx tries to update itself with a new props object.
A PureComponent
would know that the prop: a
didn't change, so it would not rerender. This happens because of the Shallow Compare utility.
You could either use the suggestion from the article (create a PureWrapper component and use it to wrap your ) or use the useCallback hook (or useMemo). Something like this:
QUESTION
I'm a little lost with a current issue in my app when rendering a checklist. react-devtools
show no performance issues, however there's a visible delay / kind of fading render appearing on the UI when selecting the Google Maps item from the list. Here are two animated screenshots with different speeds (x1.0 and x0.3):
react-devtools
shows this for rendering the changed selection:
and this for rendering a FAB
component I added in my current version:
This is also the major difference to my previous version where the issue did not appear. In my current version I make use of react-native-paper
s FAB
and FAB.Group
components:
ANSWER
Answered 2021-Mar-12 at 17:10Update: Actually the issue is that if your clustered map is animation enabled using the animationEnabled
prop here, any following UI change is animated on iOS, see here.
I now reverted my original change (see below) and simply set the animationEnabled
prop to false.
Initial answer:
Alright, found it (my fault :)) As you can see from the attached package.json
file I'm using react-native-maps
and react-navigation
. As the screen rendering the map was not dismissed by react-navigation
when navigating to the settings shown in the screenshots and changing the settings affects which map is rendered, changing the settings and the following update to the redux store trigger the hooks of my map component, thus re-rendering the screen and slowing down the app.
I addressed this issue now by using react-navigation
event listeners and unmounting the map screen whenever it loses focus.
QUESTION
I have a Node/React project in my Webstorm that won't run because of this error. I had to reinstall Windows and start fresh with my development. I got the code back into the IDE, but when I start up the Node server, I am getting the following error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
More context for that error:
...ANSWER
Answered 2020-Sep-11 at 22:23OK, I figured out the issue. I thought the error was telling me that path
was undefined. When it fact it was saying the variables passed into path.join()
were undefined. And that was because I forgot to add in my .env file to the root so it could grab those variables. Whoops!
QUESTION
I face issues with react-native-reanimated:
...ANSWER
Answered 2020-Nov-15 at 09:01Ok, I figured it out by comparing a fresh react native app with only react-native-reanimated installed and my original project.
As expected the issue was with the babel configuration, especially the wildcard plugin. I couldn't exactly figure out the reason, but applying the plugin to the whole project caused some side effects, i.e. import * as abc from './somelocation
in my node_modules not being treated correctly.
As I need the wildcard plugin only to be applied to a specific folder ./src/i18n/*
I changed my babel.config.js
as follows:
QUESTION
I'm trying to activate Hermes in a react-native project in order to improve the startup time and memory usage but when I try running it I get the following Error:
RefrenceError: Property 'Proxy' doesn't exist, js engine: hermes
I'm aware that Hermes does not support Proxy usage yet so I'm trying to identify which of my dependencies use it in order to remove it.
I've tried searching for the Proxy
keyword on my repo but I couldn't identify any reference to it. How can I detect which dependencies use it?
My dependencies are following:
...ANSWER
Answered 2020-Jul-25 at 21:19By the end of the day the package that was causing it was @ui-kitten/eva-icons
. I just had to remove it and it worked.
QUESTION
I'm working with a rails application I inherited. I'm trying to run the npm install
command but I keep getting the errors below. I tried running npm rebuild node-sass
as suggested in the output but it did not help. I'm having this problem on Ubuntu 16 as well as OS X.
ANSWER
Answered 2020-May-17 at 15:18You can use these versions:
Node: 12, NPM: 6 and node-sass: 4.12+
To fix this error, you need to fix your node and node-sass versions as per this version compatibity list. From this list, you need minimum Node 8 if you are using node-sass 4.5.3+.
I would recommend you to upgrade your nodejs and npm to latest LTS Node 12.16.3 (includes npm 6.14.4), and after that to go with node-sass
version 4.12+
. Here is how to upgrade node & npm.
To change node-sass
version, write this in your package.json: "node-sass": "^4.12.0",
.
QUESTION
I'm currently working on creating an npm package. Which is basically a React component with added styles using SCSS. When I test it out, the class names are there, but no styles are being applied.
Here is the repo for the package. I use a separated webpack config for building the specific folder where the component is.
Here's the webpack configuration I'm using:
...ANSWER
Answered 2020-Mar-21 at 15:18Looking at your repo I see that you are importing your scss but attributing it's properties to classNames.
className
should be the name of the class, and you can either attribute your imported styles to style
or you can load your compiled css into the DOM using
The reason you're not seeing a stylesheet in the network tab is because you've simply forgotten to declare a stylesheet.
QUESTION
Right now I'm using the WhyDidYourender package to verify the component re-rendering but there are few components in my repo that uses es2015. WhyDidYouRender is not working in es2015 components. Seeing below error:
...ANSWER
Answered 2020-Feb-17 at 20:56Support the ES6 or not is rely on your Browser. It's more like you trying to use the class but there is no instance to access.
Transpiled to es5 class is available in PR#8656, the whole react class elements are supported to extend with this library. If you transpile your classes by ES5 or ES6, use below code:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install why-did-you-render
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page