GithubHelp home page GithubHelp logo

Comments (12)

misuba avatar misuba commented on April 30, 2024 1

Could you post a gist? I'm pretty sure I don't need the things to work on the server... I just need them to not crash the server.

from react-modal.

ryanflorence avatar ryanflorence commented on April 30, 2024

How about including this into your app?

HTMLElement = typeof HTMLElement === 'undefined' ? function(){} : HTMLElement;
var appElement = ENV.CLIENT ?
  document.getElementById('appElement') :
  new HTMLElement();

from react-modal.

misuba avatar misuba commented on April 30, 2024

I could do that (plus shim document.body.etc - HTMLElement is just the first choke point), but I'd have to run a hacked version of this package rather than just put that in my app, and I'd prefer not to do that.

I could also possibly just require react-modal on the client-side and pass either it or a server-side alternative element all the way down my app hierarchy, but... come on. Plenty of people are running React trees in Node; it'd be nice to have a modal library that didn't require all that ducking and weaving.

from react-modal.

nelix avatar nelix commented on April 30, 2024

I had a little peek at wrapping the offending bits in ExecutionEnvironment.canUseDOM but I could not really think up a good way to do portals without the dom.

from react-modal.

nelix avatar nelix commented on April 30, 2024

@misuba this is crude and untested, just designed to give you the idea, https://gist.github.com/nelix/24dd21b12d4b005880aa

you could also not mess with react-modal at all and just render null instead if the dom is not available, but I think we could come up with a server render alternative that mostly works instead of these hacks

from react-modal.

ncuillery avatar ncuillery commented on April 30, 2024

With the @nelix 's gist augmented with the @ryanflorence 's workaround (HTMLElement = typeof HTMLElement === 'undefined' ? function(){} : HTMLElement;), it doesn't crash on server and work well in the browser.

Can we considered the issue as solved and make a new release ? :)

from react-modal.

cmeiller avatar cmeiller commented on April 30, 2024

👍

from react-modal.

fdubost avatar fdubost commented on April 30, 2024

@ncuillery 👍

from react-modal.

oziks avatar oziks commented on April 30, 2024

@ncuillery 👍

from react-modal.

XeeD avatar XeeD commented on April 30, 2024

I wonder if the work from BedrockStreaming#1 could be merged into this repository? I've just tried it and it works fine when rendering React on server for me.

from react-modal.

ncuillery avatar ncuillery commented on April 30, 2024

Yes, something similar has already been done here by @misuba : #22

from react-modal.

mzabriskie avatar mzabriskie commented on April 30, 2024

Resolved with #22

from react-modal.

Related Issues (20)

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.