Comments (16)
I have not errors, just it doesn't works
from react-modal.
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.
Server side rendering should be working with [email protected]. Let me know if you have any issues.
from react-modal.
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.
They discuss about it here:
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.
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.
@eriknyk what is the error that you get with your code?
from react-modal.
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.
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.
+1 for the same error on server side rendering. Would really love a fix for this.
from react-modal.
+1. Running into same issue on server side rendering
from react-modal.
+1 for same error with server side rendering.
from react-modal.
+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.
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.
I didn't try it yet, but it seems that a PR was merged: #70
:)
from react-modal.
@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)
- Peer dependencies not working with react 18+ HOT 6
- Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node
- Replace focus trap with `inert` HOT 1
- Focus on the input element is lost when trying to scroll modal content by dragging scrollbar
- Focus trap incorrectly finds tabbable elements HOT 11
- Modal doesn't close on the first click on the overlay after click on elements containing event.stopPropagation() inside modal HOT 11
- Add support for React & Node 18 (as easy as adding startTransition() on each setState) HOT 18
- When I try to apply css variables from css modules in React, nothing is passed HOT 9
- Npm start related issue
- Why convert position property to inset? HOT 2
- Analysis: 90% of dependency updates in this repository can be merged.
- Should use event.key not event.code
- How can i make the modal overlay non blocking? HOT 2
- Resize error when moving tab around HOT 2
- Display blurry when elements with position attributes and have scrollbars. HOT 3
- Close the modal window on the first click when using stopPropagation() HOT 3
- Replace shouldReturnFocusAfterClose={boolean} with returnFocusTo={Element} HOT 3
- Review all additional systems that react-modal uses (see helpers folder)
- Allow users to use timeout-based or css events to control modal animation.
- Use github actions
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 react-modal.