gaearon / react-deep-force-update Goto Github PK
View Code? Open in Web Editor NEWForce-updates React component tree recursively
License: MIT License
Force-updates React component tree recursively
License: MIT License
Hello, I am having problems using react-native 0.21
According to this report
facebook/react-native#5393 (comment)
it has to do with .babelrc being included in your distribution of npm.
I am not actually sure if that's the problem, or not. The solution to remove all the .babelrc from my node_modules directory does not appear to fix anything.
Therefore, I wanted to reach out to you to see if you could take a look.
my package.json does not even include deep-force-update
"engines": { "node": ">=4", "npm": ">=2 <4"
},
"devDependencies": {
"babel-core": "^6.6.5",
"babel-register":"^6.6.0",
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.0",
"babel-preset-react-native": "^1.5.1",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"eslint": "^2.2.0",
"eslint-loader": "^1.1.1",
"eslint-plugin-react": "^4.0.0",
"react-native-webpack-server": "^0.8.4",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
},"dependencies": {
"react-native": "^0.21.0",
"@remobile/react-native-splashscreen": "^1.0.3",
"react-native-blur": "^0.7.10",
"react-native-htmlview": "^0.2.0","react-native-material-kit": "^0.3.0",
"react-native-material-design": "^0.3.3"
}
got error deepForceUpdate is not a function
reinstall 2.1.1 solved this.
I use this to update components that use context to get translation strings after the language was switched.
I know this uses internal APIs, but using this is much nicer than either constantly managing 100+ listeners or force-rerendering the app through a key
on the root element.
It would be even nicer if it would only update components that use the context in the first place. Would that be difficult to do? Would you accept a PR that does this?
The new version crashes for me on this line: https://github.com/gaearon/react-deep-force-update/blob/master/src/index.js#L65 . Using React v15
This happens on a div that has html content set. Neither of the two attributes are there, but interestingly there is a instance.__reactInternalInstance$wfzkogjc2v
, not sure what creates that.
Would it be sufficient to just guard against undefined root
and return
?
Hello,
Is anyone here can help me to integrate this tool (v1.x) with wix react-native-navigation library which builds its component stack a bit differently ?
Thanks
Hi,
It seems there is an issue with the package.
npm install gaearon/react-deep-force-update doen't add the lib.
I needed to clone it to be able to add the sources.
Have a good day
Dorian
This pertains to v4 beta 13, which code is not to be found in this repo :(
the beta checks node.tag and only processes nodes where node.tag === 2
. However, in React v16.6 it seems that almost all nodes are a 1
.
Hence, no updates.
forceUpdate is ignored by react-redux connect. Because internally a renderedElement
is stored and forceUpdate does not reset this element, leading to rendering an possibly 'old' component. A fix could be like adding this code to deepForceUpdate
. Or update react redux connect to handle forceUpdate
.
traverseRenderedChildren(node, internalInstance => {
const instance = internalInstance._instance;
if (instance && instance.renderedElement) {
instance.renderedElement = null;
}
});
Looking at #6 again, I understand now that onUpdate
and shouldUpdate
"leak" internal instances to the user code. Can we please avoid this? Let's change the code to take the limited amount of information you need (e.g. an object containing the fields you're interested in). We can add more fields but I don't want to make internal structure exposed.
@bfiss Could you please change this?
I'm not entirely sure, but I think CI runs don't test all the Fiber code. It's very important to also test that code :)
var root = ReactDOM.render(<React.Fragment><A /><B /></React.Fragment>);
deepForceUpdate(root); // does not update component B
Eyeing the code, the early return on https://github.com/gaearon/react-deep-force-update/blob/master/src/index.js#L84 should probably move to after the sibling loop to make this case work.
Hi, I updated my app to react-native 0.64.2 from 0.63.x and your package don't work on ios release mode.
I have this error in xcode logs :
[javascript] TypeError: undefined is not an object (evaluating ‘f.tag’)
This error is located at:
in l
in Connect(l)
in f
in Unknown
After some investigations, I use redux-i18n that is using react-deep-force-update
The problem is in :
var root = instance._reactInternalFiber || instance._reactInternalInstance;
if (typeof root.tag !== 'number') {
// Traverse stack-based React tree.
return deepForceUpdateStack(instance, shouldUpdate, onUpdate);
}
root is undefined and can't find tag property.
thx
Jeremie.
I saw the README
mentions that it works on React Native but doesn't explain how as we don't have instance of rendered tree as we do with react-dom
. Can somebody please point me out on how we get react tree instance? Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.