Git Product home page Git Product logo

Comments (1)

polytypic avatar polytypic commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.