Skip to content

Commit

Permalink
reproduce freeze more consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
superhawk610 committed Oct 31, 2018
1 parent 59c42e9 commit b617e8b
Show file tree
Hide file tree
Showing 15 changed files with 368 additions and 96 deletions.
4 changes: 4 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
singleQuote: true
trailingComma: all
tabWidth: 2
semi: true
75 changes: 71 additions & 4 deletions build/Index.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<div id="page-wrapper">
<div id="root"></div>
</div>
<script type="text/javascript" src="Index.js"></script>
</body>
<script type="text/javascript" src="./Index.js"></script></body>

</html>
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
"author": "Aaron Ross <[email protected]>",
"license": "MIT",
"dependencies": {
"bulma": "^0.7.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"reason-react": ">=0.4.0"
},
"devDependencies": {
"bs-platform": "^4.0.7",
"css-loader": "^1.0.1",
"html-webpack-plugin": "^3.2.0",
"style-loader": "^0.23.1",
"webpack": "^4.0.1",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.8"
Expand Down
2 changes: 2 additions & 0 deletions src/Index.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Index.re
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
[%bs.raw {|require("bulma/css/bulma.css")|}];

ReactDOMRe.renderToElementWithId(<App />, "root");
2 changes: 1 addition & 1 deletion src/components/App/App.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/components/App/App.re
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
let component = ReasonReact.statelessComponent("App");

let make = (_children) => {
let make = _children => {
...component,
render: (_self) => (
<div>
<Greeting name="Aaron" />
<Stateful greeting="foo" />
</div>
),
render: _self => <div> <Greeting name="Aaron" /> <Stateful /> </div>,
};
35 changes: 35 additions & 0 deletions src/components/Button/Button.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/components/Button/Button.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let component = ReasonReact.statelessComponent("Button");

let make = (~text, ~onClick, _children) => {
...component,
render: _self =>
<button onClick className="button"> (ReasonReact.string(text)) </button>,
};
51 changes: 14 additions & 37 deletions src/components/Stateful/Stateful.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 13 additions & 29 deletions src/components/Stateful/Stateful.re
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
type state = {
count: int,
show: bool,
};
type state = {count: int};

type action =
| Increment
| Decrement
| Toggle;
| Decrement;

let component = ReasonReact.reducerComponent("Stateful");

let make = (~greeting, _children) => {
let make = _children => {
...component,
initialState: () => {count: 0, show: true},
initialState: () => {count: 0},
reducer: (action, state) =>
switch (action) {
| Increment => ReasonReact.Update({...state, count: state.count + 1})
| Decrement => ReasonReact.Update({...state, count: state.count - 1})
| Toggle => ReasonReact.Update({...state, show: !state.show})
| Increment => ReasonReact.Update({count: state.count + 1})
| Decrement => ReasonReact.Update({count: state.count - 1})
},
render: self => {
let message = "You've clicked this " ++ string_of_int(self.state.count) ++ " times(s)";
render: self =>
<div>
<button onClick=(_event => self.send(Increment))>
(ReasonReact.string("-"))
</button>
<button onClick=(_event => self.send(Decrement))>
(ReasonReact.string("+"))
</button>
<button onClick=(_event => self.send(Toggle))>
(ReasonReact.string("Toggle greeting"))
</button>
(
self.state.show
? ReasonReact.string(greeting)
: ReasonReact.null
)
</div>;
},
<Button text="-" onClick=(_event => self.send(Decrement)) />
<div className="foo">
(ReasonReact.string(string_of_int(self.state.count) ++ "foo"))
</div>
<Button text="+" onClick=(_event => self.send(Increment)) />
</div>,
};
1 change: 0 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<div id="page-wrapper">
<div id="root"></div>
</div>
<script type="text/javascript" src="Index.js"></script>
</body>

</html>
35 changes: 24 additions & 11 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const outputDir = path.join(__dirname, 'build/');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const outputDir = path.resolve(__dirname, 'build/');

const isProd = process.env.NODE_ENV === 'production';

Expand All @@ -9,19 +9,32 @@ module.exports = {
mode: isProd ? 'production' : 'development',
output: {
path: outputDir,
publicPath: outputDir,
publicPath: './',
filename: 'Index.js',
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: false
})
],
// plugins: [
// new HtmlWebpackPlugin({
// template: 'src/index.html',
// inject: 'body',
// }),
// ],
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
watch: true,
watchOptions: {
ignored: /node_modules/,
},
devServer: {
hot: true,
compress: true,
contentBase: outputDir,
port: process.env.PORT || 8000,
historyApiFallback: true
}
historyApiFallback: true,
},
};
Loading

0 comments on commit b617e8b

Please sign in to comment.