Comments (1)
Yes, the current behaviour and workaround is mentioned in the README:
If you need to have observable children inside the provider, you can wrap the children inside a
Fragment
.
It should be possible to wrap createContext
to return a Provider
whose children, but not other properties, are lifted. Aside from the additional implementation complexity, I think I didn't do that, because that would be different from the way lifting otherwise works. Thinking about this now, I'm not yet sure whether special case lifting of children should be done in this case. As you say, it would usually do the right thing, but, OTOH, it would be a special case and as such might be surprising.
Another thing here is that for some reason React is warning about missing keys when using children inside the React.Fragment.
Hmm... That seems to be caused by having both a non-observable child and an observable child. You can e.g. explicitly give a key for the observable child <Child key="something"/>
or wrap the observable inside a span
or div
to silence the warning. React automatically assigns keys in a static list of elements, but in this case the list is not static. Perhaps it is possible to work around this inside Karet. I'm not immediately sure.
BTW, note that you can also write <>...</>
instead of <React.Fragment>...</React.Fragment>
in the Sandbox. (Works when you have Babel 7 or TS, for example.)
from karet.
Related Issues (15)
- Do not call `forceUpdate` during mounting HOT 2
- Lift contents of `dangerouslySetInnerHTML` HOT 1
- How does it work? HOT 2
- Implement template string helpers for detecting observers HOT 1
- Accept ES7 Observables instead of Kefir HOT 3
- Help needed in porting this to RxJS HOT 3
- karet and lists of children HOT 1
- Respond to React lifecycle methods? HOT 2
- Pass through React Hooks
- Add jsx-runtime support HOT 1
- Consider supporting `React.cloneElement` HOT 1
- Breaking change: reconsider exports HOT 1
- Support different VDOM implementations HOT 6
- Support arbitrarily nested children
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 karet.