Comments (9)
I have released [email protected]
to include this functionality as addCallback
. The documentation for addCallback
has been added to the README.
I added some unit tests and manual app testing to try to insure there were no breaking changes, but this version included a major change to some internal workings. I would love some community feedback on if any errors are discovered.
Thank you for your patience. I'm sorry about the long delay. I have been unable to contribute for the past month, but I'm hoping to begin knocking out a lot of ReactN's open issues now.
from reactn.
I understand. You want persistence of state between application launches.
I think "afterware" support may allow for this. Something like useAfterware(functionThatReceivesStateOnChange)
will allow custom functionality, like writing to storage when the state changes.
useAfterware(function(global) {
persistentStorage.set('global', JSON.stringify(global));
});
// The above function executes with the new global state whenever setGlobal occurs.
If something like this sounds good to you, I'll mark it as TODO. I want to make sure it matches your use case.
from reactn.
This has not been done yet. I have been out for various reasons the past month and have returned to my development life as of today.
from reactn.
Are you talking about for SSR? Can you elaborate on how you want state to persist and how you would want it to rehydrate?
from reactn.
I'm changing this to just a request for state persistence, as rehydration between server and client exists as issue #9.
I would still need more information to tackle this request, though. I'm not sure what specifically you are requesting in relation to a React Native application.
from reactn.
Hi! sorry for the delay. My request was not about server side rendering, it was about persistence and (after cold start) retrieving that data from storage (the term rehydration means that in redux persistence - https://github.com/rt2zz/redux-persist). It just handles the 'asynchronicity' of a cold start to initialize the store with the latest bunch of data, IIUC
from reactn.
Yes, I think that would cover the lifecycle of any mobile app
(which usually follow an offline-first
approach).
Used in conjunction with componentDidMount (pseudo code):
//based in the example from reactn/Examples/Class Components
export default class MyView extends React.Component {
...
componentDidMount() {
persistentStorage.get('global', (value)=>{
this.setGlobal(
JSON.parse(value)
)
})
}
render() {
...
}
Thanks for your work.
from reactn.
Was this implemented? Is there a way to hook into setGlobal with the current release?
from reactn.
I'd just like to state that I have this existing in my local repository (using the name addCallback
), but it's pretty important to me that I get unit tests completed for the project as a whole before cutting a new version, so I do not have an ETA on release. I may do an alpha release if the unit tests delay this too much.
from reactn.
Related Issues (20)
- Can we drop in preact in place of React while using Reactn? HOT 1
- Global state resets after Route change HOT 5
- Don't export functions with the same name as common React hooks HOT 1
- [Query] Does updating a global nested state, require deep copy ? HOT 2
- why is useEffect exported from the package? HOT 2
- Dependabot can't resolve your JavaScript dependency files
- Provider.useDispatch Errors with TypeScript HOT 1
- Global reducers do not work in TypeScript 4. HOT 4
- Ability to update state with a function with globalPropertySetter HOT 1
- React Native expo HOT 2
- react native compatible? HOT 5
- Feature request: add previous global state to addCallback parameters HOT 10
- useEffect in useGlobal has no dependencies and will run every render HOT 1
- Document how to put arrays and etc. in global state HOT 6
- Unwanted batch rendering
- Argument of type 'string' is not assignable to parameter of type 'never' HOT 3
- Dispatch re-renders components even when state is unchanged. HOT 2
- Set `peerDependencies` to `"@types/react": "^16.8.0 | ^17.0.2"` HOT 2
- Issue resolving dependency to `use-force-update` in react-native/expo project HOT 7
- Dependency Use force update 1.0.10 causes a Type Error HOT 7
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 reactn.