Skip to content

Commit 630bed8

Browse files
authored
fix(ssr): Fix server side rendering (#37)
1 parent 0c29346 commit 630bed8

8 files changed

Lines changed: 26 additions & 5 deletions

File tree

.DS_Store

-6 KB
Binary file not shown.

example/dist/example.js

Lines changed: 5 additions & 1 deletion
Large diffs are not rendered by default.

example/dist/example.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ReactCodeInput.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ReactCodeInput.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "lib/ReactCodeInput.js",
66
"scripts": {
77
"start": "gulp bluekit:build && webpack && webpack-dev-server --content-base example/",
8-
"build": "gulp bluekit:build && webpack && cd styles && sass style.scss style.css",
8+
"build": "gulp bluekit:build && webpack && cd styles && sass style.scss style.css && cd ../ && ./postbuild.sh",
99
"test": "cross-env NODE_ENV=test jest --silent",
1010
"test:coverage": "cross-env NODE_ENV=test jest --silent --coverage",
1111
"codecov": "codecov -f ./coverage/*.json",

postbuild.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
text="if (typeof window === 'undefined') {
3+
global.window = {};
4+
}"
5+
6+
file="./lib/ReactCodeInput.js"
7+
8+
echo -e "$text\n$(cat $file)" > $file

src/ReactCodeInput.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2016 Konstantin Kulinicenko.
3+
* Licensed under the MIT License (MIT), see
4+
* https://github.com/40818419/react-code-input
5+
*/
6+
17
import React, { Component } from 'react';
28
import PropTypes from 'prop-types';
39
import classNames from 'classnames';

0 commit comments

Comments
 (0)