Skip to content

Commit 91d7a8a

Browse files
committed
react-playground initial commit
0 parents  commit 91d7a8a

File tree

7 files changed

+88
-0
lines changed

7 files changed

+88
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# React Playground
2+
3+
This simple repository is useful for testing React features and profiling. Since we are pulling
4+
dependencies from CDN, there's no need for installing, bundling or configuring anything. Just clone
5+
the repo and play with React.
6+
7+
The idea is to completely remove any side effects and focus purely on React and its ecosystem.
8+
9+
If you create new components or any JSX files in general, don't forget to include them under your
10+
index.html scripts.
11+
12+
_This repository is not inteded for providing production ready tooling nor for builing projects in general. You should primarly use it as a playground to test out internal features, measure preformances and similar._
13+
14+
## What's included
15+
16+
- React 16
17+
- ReactRedux
18+
- ReactDOM
19+
- Redux
20+
21+
Don't forget to add all the nasty React and Redux tools for your browser.

app.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class App extends React.Component {
2+
render() {
3+
return <Main />;
4+
}
5+
}
6+
7+
ReactDOM.render(<App />, document.getElementById('react-app'));

components/Main.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const Main = props => {
2+
return (
3+
<ReactRedux.Provider store={store}>
4+
<Message />
5+
</ReactRedux.Provider>
6+
);
7+
};

components/Message.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Message extends React.Component {
2+
changeMessage = () => {
3+
this.props.dispatch({ type: 'BAZ_ACTION', payload: 'bazzing' });
4+
};
5+
render() {
6+
return (
7+
<React.Fragment>
8+
<h1>{this.props.foo}</h1>
9+
<button onClick={this.changeMessage}>Change me</button>
10+
</React.Fragment>
11+
);
12+
}
13+
}
14+
15+
Message = ReactRedux.connect(state => state)(Message);

index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
9+
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
10+
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
11+
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/redux/4.0.0/redux.min.js"></script>
12+
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/react-redux/5.0.7/react-redux.min.js"></script>
13+
<title>React Playground</title>
14+
</head>
15+
16+
<body>
17+
<div id="react-app"></div>
18+
<script type="text/babel" src="store/reducers/foo.reducer.js"></script>
19+
<script type="text/babel" src="store/index.js"></script>
20+
<script type="text/babel" src="components/Main.jsx"></script>
21+
<script type="text/babel" src="components/Message.jsx"></script>
22+
<script type="text/babel" src="app.jsx"></script>
23+
</body>
24+
25+
</html>

store/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const store = Redux.createStore(
2+
fooReducer,
3+
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
4+
);

store/reducers/foo.reducer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const BAZ_ACTION = 'BAZ_ACTION';
2+
3+
const fooReducer = (state = { foo: 'bar' }, action) => {
4+
switch (action.type) {
5+
case BAZ_ACTION:
6+
return Object.assign({}, { foo: action.payload });
7+
}
8+
return state;
9+
};

0 commit comments

Comments
 (0)