drcmda / immer-wieder Goto Github PK
View Code? Open in Web Editor NEW✨ React 16 context wrap with redux semantics powered by immer
License: MIT License
✨ React 16 context wrap with redux semantics powered by immer
License: MIT License
Hi,
I wonder if it's possible to use the context of immer-wieder as contextType in components : https://reactjs.org/docs/context.html#classcontexttype
src/index.js
componentDidMount() {
this.mounted = true
}
componentWillUnmount() {
this.mounted = true
}
I would have thought you set it false for unmount so no batched setState calls attempt to run on the unmounted component.
If it's intentional, could you explain briefly what's going on?
Hi
Would you consider this llibrary production ready? eg. have you used it in any bigger application?
I also see you have react-contextual, would that be a better choice in your opinion?
Thanks in advanced.
Kind regards
Dennis
Hi, thanks for the great lib, I'm really enjoying working with it so far.
I'm wondering if you have any suggestions for how I can implement history in my store. I'm struggling to grasp it because the store is only accessible as a draft inside setState, which is always going to be mutated, so as far as I can understand I can only ever do something like draft.history.push( draft )
or draft.history.push( draft.someProp )
within some existing action. Would that make sense? And then could I later even revert to it doing draft = draft.history.pop()
or something along those lines?
I haven't really interacted directly with immer (only learned about it through your lib), but obviously draft is not a POJO. Should I look there? Is Middleware the right usecase for this? I'm really not sure...
Anyway I'm going to start trying various approaches and I'd greatly appreciate any insights you can provide to be able to wrap my head around this. Thanks!
A child component wrapped with hoc
can't invoke setState in componentDidMount
because this.mounted is false.
I have a codesandbox demonstrating this, an action is invoked in componentDidMount
, but the setState
will not execute.
https://codesandbox.io/s/9zonjjq3k4
If you have any ideas, I'm up for doing a pr. I'm not exactly sure why the this.mounted
check is required
Great lib though :)
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.