GithubHelp home page GithubHelp logo

Comments (16)

eriknyk avatar eriknyk commented on April 30, 2024 2

I have not errors, just it doesn't works

from react-modal.

 avatar commented on April 30, 2024 2

This has been open for quite some time. Given the amount of people struggling with isomorphic rendering it's perhaps worth mentioning this library works client-side only in the project README.md.

from react-modal.

mzabriskie avatar mzabriskie commented on April 30, 2024 1

Server side rendering should be working with [email protected]. Let me know if you have any issues.

from react-modal.

kilianc avatar kilianc commented on April 30, 2024 1

Just be clear, it doesn't throw any error, it just doesn't render the modal and I can't find any examples that show how to change the mount-point in a server-side compatible manner.

from react-modal.

mammut avatar mammut commented on April 30, 2024

They discuss about it here:

#15

but the Modal.injectCSS() still gave me problems, so I ended up doing this:

var React = require('react');
var Modal = require('react-modal');
var ExecutionEnvironment = require('react/lib/ExecutionEnvironment');

if (ExecutionEnvironment.canUseDOM) {
  Modal.injectCSS();
  Modal.setAppElement(document.getElementById('react-app'));
}
...

The server stopped crashing and it works on the frontend.

from react-modal.

eriknyk avatar eriknyk commented on April 30, 2024

Hi,

I tried something like this,

import React, { Component, PropTypes } from 'react';

var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
var Modal = require('react-modal');

export default class Emails extends Component {    
    constructor(props, context) {
        super(props, context);

        this.state = {
            modalOpen: false
        };
    }

    componentDidMount () {
    ​    var appElement = React.findDOMNode(this);

        Modal.setAppElement(appElement);
        Modal.injectCSS();
    }

    render () {
        return (
            <div>
                <Modal
                        isOpen={this.state.modalOpen}
                        onRequestClose={this.closeModal}
                        >
                        <h2>Hello</h2>
                        <button onClick={this.closeModal}>close</button>
                        <div>I am a modal</div>
                        <form>
                            <input />
                            <button>tab navigation</button>
                            <button>stays</button>
                            <button>inside</button>
                            <button>the modal</button>
                        </form>
                    </Modal>
            </div>);
    }

    openModal() {
        this.state = {
            modalOpen: true
        };
    }

    closeModal() {
        this.state = {
            modalOpen: false
        };
    }

    getStoreState () {
        return {
            modalOpen: this.context.getStore(EmailsStore).isModalOpen()
        };
    }
}

but still it doesn't works,..
Any other suggestion to make it works on a isomorphic app?

Regards.

from react-modal.

mzabriskie avatar mzabriskie commented on April 30, 2024

@eriknyk what is the error that you get with your code?

from react-modal.

pwmckenna avatar pwmckenna commented on April 30, 2024

this happens just trying to run webpacked code server side:

/Users/patrickwilliams/git/frontend-home-profile/node_modules/react-modal/lib/helpers/ariaAppHider.js:1
 (exports, require, module, __filename, __dirname) { var _element = document.b
                                                                    ^
ReferenceError: document is not defined
    at Object.<anonymous> (/Users/patrickwilliams/git/frontend-home-profile/node_modules/react-modal/lib/helpers/ariaAppHider.js:1:78)
    at Module._compile (module.js:460:26)
    at Module._extensions..js (module.js:478:10)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/patrickwilliams/git/frontend-home-profile/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:214:7)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.cls_wrapMethod (/Users/patrickwilliams/git/frontend-home-profile/node_modules/newrelic/lib/shimmer.js:230:38)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/patrickwilliams/git/frontend-home-profile/node_modules/react-modal/lib/components/Modal.js:4:20)

from react-modal.

staminaloops avatar staminaloops commented on April 30, 2024

Same error. Even with

var ExecutionEnvironment = require('react/lib/ExecutionEnvironment');

if (ExecutionEnvironment.canUseDOM) {
Modal.injectCSS();
Modal.setAppElement(document.getElementById('react-app'));
}
...

We are using server side rendering, so yes, document it's not defined on server.
I think it's a priority fixing this, since many of us are using server side rendering :)

from react-modal.

nhatquang238 avatar nhatquang238 commented on April 30, 2024

+1 for the same error on server side rendering. Would really love a fix for this.

from react-modal.

shilpam avatar shilpam commented on April 30, 2024

+1. Running into same issue on server side rendering

from react-modal.

shaharyakir avatar shaharyakir commented on April 30, 2024

+1 for same error with server side rendering.

from react-modal.

kalasjocke avatar kalasjocke commented on April 30, 2024

+1 over here for supporting server side rendering.

If you need a short term solution you can downgrade to 0.3.0 which supports server side rendering.

from react-modal.

eriknyk avatar eriknyk commented on April 30, 2024

at the end I make it works, but without any styles,.. seems Modal.injectCSS(); is not working as expected or I need to add some stylesheets manually?

from react-modal.

staminaloops avatar staminaloops commented on April 30, 2024

I didn't try it yet, but it seems that a PR was merged: #70
:)

from react-modal.

kilianc avatar kilianc commented on April 30, 2024

@mzabriskie can you be more specific, I am still experiencing this, what changed and is there an example somewhere I can look at?

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.