Comments (4)
To @liquidprogrammer , the fix looked something like this in the template:
<encounter-view
id="encounter-view-ng"
ng-if="$ctrl.includeEncounterView"
Where EncounterView is the react2angular component.
Then when changing states away from this route, I set includeEncounterView to false and wait until the view is torn down before proceeding to the route.
$scope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
if (toState.name !== 'home.patients.details.coding.encounter') {
this.includeEncounterView = false;
if ($('#encounter-view-ng').length) {
event.preventDefault();
const checkTornDownInterval = $interval(() => {
if (!$('#encounter-view-ng').length) {
$interval.cancel(checkTornDownInterval);
$state.go(toState, toParams);
}
}, 0);
}
}
@brianunlam, It's been a while since I looked at this. SInce I reported this bug, I discovered that React seems to hang onto references and free them periodically. This means that you might need to take a memory snapshot, perform an operation that shouldn't leak and then WAIT before taking another snapshot - if you do this too quickly, you might see leaks that don't really exist.
But in this case, it did seem like the memory was steadily increasing. I don't know, this leak/non-leak was driving me a little bit crazy. Now I have code that I'm afraid to touch. ;)
I asked about React hanging onto references here BTW:
https://stackoverflow.com/questions/58984601/reactdom-seems-to-be-caching-and-releasing-elements-so-is-this-a-leak
Thanks for a great and useful library. I don't think it's the culprit here.
from react2angular.
Hi @scottschafer! Im facing the same issue, can u please provide an example of ur hacky ng-if
fix? I tried do that ng-if
hack somewhere on the top level of routing, but memory was still leaked (but less than without that). Just wanted to double check where in the app u apply that trick so it helps to avoid leaks
from react2angular.
@scottschafer how did you do to get the leaks that way?
memLeak in EncounterView@711833 | 11 | 1360 % | 100 001 32852 %
stateNode in FiberNode@708915 | 10 | 2880 % | 100 001 61652 %
lastEffect in FiberNode@707329 | 9 | 2880 % | 100 007 13652 %
currentFiber in system / Context@90437 | 8 | 11 6080 % | 100 539 41652 %
context in overrideHookState()@68727 | 7 | 640 % | 1680 %
from react2angular.
@scottschafer hi, thanks! I'll try that out. I didn't try to ng-if
the component itself, i only tried to add ng-if
at the top level root component, but that helped only a bit.
from react2angular.
Related Issues (20)
- Is it possible to pass function with params from angular parent component to react child component with react2angular library? HOT 1
- Collision of React Props and Angular Component Class Members HOT 1
- Doesnt work correct in table HOT 1
- No documentation on function binding incompatibility HOT 1
- React hooks HOT 5
- How to share React Context with Angular HOT 3
- How to provide redux store store? HOT 2
- Uncaught SyntaxError: Cannot use import statement outside a module
- Is it works with TypeScript? HOT 2
- Angular 10 support?
- Does this support React.lazy component HOT 1
- How can I render children inside the react component? HOT 2
- Issue when bundling
- Critical Vulnerability in react2angular > ngcomponent > lodash path
- Webpack Module Federation Support
- angularApp.component is not a function HOT 1
- React 18 upgrade HOT 4
- React 18 Support HOT 3
- Are React functional components supported? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react2angular.