forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fixed] server side rendering for Modal component
Using document reference in the render method will throw an error on React.renderToString call on the server side. See react-bootstrap#717. The proper solution is to remove document.querySelector check. Obviously we cant detect this feature on the server side, besides it leads to differencies btw server and client side rendering output, so React will warn about it, ex: 1. `render` on the server side will apply classes: `modal fade` 2. `render` on the client side will apply clasess: `modal fade in` Also karma test environment is not suitable for testing server side rendering, so mocha test run againt nodejs was added.
- Loading branch information
Showing
3 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import {assert} from 'chai'; | ||
import Modal from '../../src/Modal.js'; | ||
|
||
describe('Modal', () => { | ||
it('Should be rendered on the server side', function () { | ||
let noOp = () => {}; | ||
|
||
assert.doesNotThrow(function renderOnServerSide() { | ||
return React.renderToString( | ||
<Modal onRequestHide={noOp}> | ||
<strong>Message</strong> | ||
</Modal> | ||
); | ||
}); | ||
}); | ||
}); |