Giter VIP home page Giter VIP logo

react-tunnels's People

Contributors

albinekb avatar brunolemos avatar javivelasco avatar jossmac avatar mark-partola avatar timothykrell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-tunnels's Issues

Suboptimal approach to render props

Looks like the implementation of TunnelPlaceholder is treating render props as if they were full fledged components by using React.creatElement.

While this is cool because it let you expose a double API:

<TunnelPlaceholder>
  {props => <MyComponent {...props} />}
</TunnelPlaceholder>

// is equal to

<TunnelPlaceholder>
  {MyComponent}
</TunnelPlaceholder>

But this has a major caveat: when using the render-prop API every re-render will unmount and remount the whole placeholder children!

This is because between different render phases React thinks this is a completely new component and that it cannot reconciliate in any way.

What you actually want to achieve (probably) is something along the lines of what react-router does by exposing three different props:

  • render which is a render prop,
  • children which is a render prop,
  • component which is treated as a ComponentType or a Functional Stateless Component.

And you can have a look at how they implement their #render method too.

Iโ€™ll make a PR soon so that if you are ok with the approach you can accept it right away.

import from 'preact-slots'

The readme example imports from preact-slots, was that intentional?
There is no preact dependency on package.json so I assume it was not.

Using a tunnel right away?

So I have the code below.
SomeComponentThatRendersToTunnel will try to put something inside footer-tunnel but it wont show on first render. My guess is that it's because it's below what will try to put something inside it. If I move the tunnel above the component it does render.

Is this a bug or expected? Is there a way to get around it?

<TunnelProvider>
                <>
                        <SomeComponentThatRendersToTunnel />
                        <div className={styles.flexFooter}>
                            <TunnelPlaceholder id="footer-tunnel" />
                        </div>
                </>
</TunnelProvider>

Redirect react context

Currently the tunneled component reads the context of where it is rendered at. It would be useful to redirect the context the same way it is done with props.

If you don't have time to do it, do you think it would be possible?

What about using react portals to render children into DOM nodes rendered and registered by other react components previously? React portals do redirect context. Do you see any potential problem with that?

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.