Comments (8)
from preact-context.
Hey George,
Sounds good, thanks!
Had a quick look, and if I change the Consumer
component's shouldComponentUpdate
method to just return true;
it works as expected. So maybe it's an issue with the condition here?:
Lines 85 to 88 in 74217c0
from preact-context.
Actually, although changing it to return true;
fixes the test case above, it doesn’t fix the original issue that I’m having on a project (again, it works fine with React.createContext
). I will create another reduced test case for that if I can.
Edit: the issue on my project was actually caused by this preact bug, so you can disregard this comment
from preact-context.
@bradlc the problem is that preact mutates the state instance on each update hence the this.state.value !== nextState.value
check is always true. You have to make sure that you pass a new instance of the value to the Context.Provider (ex: <Context.Provider value={{ ...this.state }}>
, see your updated example).
from preact-context.
I'll try to catch up with some of the preact
maintainers in order to provide a proper solution for that as it looks like it will be a problem that many preact users might have.
from preact-context.
This issue is caused by using an older release of preact
. With the most recent version 8.3.1
I can't reproduce the issue anymore and the example works exactly the same as for react
.
from preact-context.
You’re right, updating the CodeSandbox to 8.3.1
fixes the issue. Thanks!
from preact-context.
thanks a lot for the clarification @marvinhagemeister !
from preact-context.
Related Issues (17)
- unstable_observedBits in react new context API HOT 1
- Getting error consumer used without provider. HOT 3
- Build Error, Node v8.0.0 or v8.11.3 HOT 2
- Tyepscript Issue with provider value HOT 2
- Aliasing create-react-context HOT 3
- Uglify mangling `window.__extends` HOT 2
- Adding a child consumer while updating provider value does not render the last consumer child correctly HOT 3
- Make warning optional: Consumer used without a Provider HOT 3
- empty value HOT 1
- Add example how access context value in Component code HOT 1
- How to provide it to dependencies? HOT 1
- Is there any way to have access to this.context in component code? HOT 10
- Should the main README mention that Preact core now supports the new Context API?
- Uncaught ReferenceError: preact is not defined HOT 2
- Question: Tag name HOT 2
- Issue with typescript enums 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 preact-context.