Skip to content

Instantly share code, notes, and snippets.

@kmcluckie
Created November 10, 2015 09:13
Show Gist options
  • Save kmcluckie/457b1a991db379b2719d to your computer and use it in GitHub Desktop.
Save kmcluckie/457b1a991db379b2719d to your computer and use it in GitHub Desktop.
Number Editor Test
import React from 'react';
import ReactDOM from 'react-dom';
import NumberEditor from 'react-number-editor';
main();
function main() {
const app = document.createElement('div');
document.body.appendChild(app);
ReactDOM.render(<NumberEditor min={0} max={1} step={0.01} decimals={2} />, app);
// If you try render this it'll work fine
// ReactDOM.render(<div>Hello</div>, app);
}
{
"name": "number-editor-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^5.8.25",
"babel-loader": "^5.3.2",
"babel-plugin-react-transform": "^1.1.1",
"css-loader": "^0.20.1",
"html-webpack-plugin": "^1.6.2",
"react-transform-hmr": "^1.0.1",
"style-loader": "^0.12.4",
"webpack": "^1.12.2",
"webpack-dev-server": "^1.12.1",
"webpack-merge": "^0.2.0",
"es6-promise": "^3.0.2"
},
"dependencies": {
"react": "^0.14.1",
"react-dom": "^0.14.1",
"react-number-editor": "^3.1.0"
}
}
require('es6-promise').polyfill();
var path = require('path');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
var merge = require('webpack-merge');
var TARGET = process.env.npm_lifecycle_event;
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'app');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');
process.env.BABEL_ENV = TARGET;
var common = {
entry: APP_PATH,
resolve: {
extensions: ['', '.js', '.jsx']
},
output: {
path: BUILD_PATH,
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.css$/,
loaders: ['style', 'css'],
include: APP_PATH
},
{
test: /\.jsx?$/,
loaders: ['babel'],
include: APP_PATH
}
]
},
devServer: {
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
port: 3000,
host: '0.0.0.0'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlwebpackPlugin({
title: 'Number Editor Test'
})
]
};
if(TARGET === 'start' || !TARGET) {
module.exports = merge(common, {
devtool: 'eval-source-map',
devServer: {
historyApiFallback: true,
hot: true,
inline: true,
progress: true
},
plugins: [
// new webpack.HotModuleReplacementPlugin() // removed because of error (Uncaught RangeError: Maximum call stack size exceeded)
]
});
}
@kmcluckie
Copy link
Author

Note: index.jsx is in the app/ directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment