Преглед на файлове

updated react/redux to recent practices

Brandon Wong преди 7 години
родител
ревизия
2c72000907
променени са 11 файла, в които са добавени 27 реда и са изтрити 25 реда
  1. 0 18
      front/App.js
  2. 1 0
      front/actions.js
  3. 11 0
      front/components/App.js
  4. 2 0
      front/components/styles/App.css
  5. 0 0
      front/epics/index.js
  6. 1 1
      front/index.js
  7. 6 1
      front/main.sh
  8. 0 0
      front/reducers/index.js
  9. 2 2
      front/store.js
  10. 3 2
      utils/exampleComponent.js
  11. 1 1
      utils/reduxadder.sh

+ 0 - 18
front/App.js

@@ -1,18 +0,0 @@
-import React from 'react';
-import logo from './logo.svg';
-import './App.css';
-
-export default function App() {
-    return (
-        <div className="App">
-            <header className="App-header">
-                <img src={logo} className="App-logo" alt="logo" />
-                <h1 className="App-title">Welcome to React</h1>
-            </header>
-            <p className="App-intro">
-                To get started, edit <code>src/App.js</code> and save to reload.
-            </p>
-        </div>
-    );
-}
-

+ 1 - 0
front/actions.js

@@ -0,0 +1 @@
+/* action creators go here */

+ 11 - 0
front/components/App.js

@@ -0,0 +1,11 @@
+import React from 'react';
+import './styles/App.css';
+
+export default function App() {
+    return (
+        <div>
+            my awesome app
+        </div>
+    );
+}
+

+ 2 - 0
front/components/styles/App.css

@@ -0,0 +1,2 @@
+/* styling for the App */
+

front/epics.js → front/epics/index.js


+ 1 - 1
front/index.js

@@ -6,7 +6,7 @@ import { ConnectedRouter } from 'react-router-redux';
 import store, { history } from './store.js';
 import registerServiceWorker from './registerServiceWorker.js';
 
-import App from './App.js';
+import App from './components/App.js';
 
 ReactDOM.render(<Provider store={store}>
     <ConnectedRouter history={history}>

+ 6 - 1
front/main.sh

@@ -45,7 +45,12 @@ sed -i 's_  </head>_\n    <!-- Bootstrap CSS -->\n    <link rel="stylesheet" hre
 
 
 # copy files
-cp $script_folder/App.js $script_folder/epics.js $script_folder/index.js $script_folder/reducers.js $script_folder/store.js src/
+cp -R $script_folder/* src/
+rm -f src/main.sh
+
+# delete or move some existing files
+rm -f src/App.js src/App.css src/logo.svg
+mv src/App.test.js src/components/App.test.js
 
 
 # initialize git

front/reducers.js → front/reducers/index.js


+ 2 - 2
front/store.js

@@ -3,8 +3,8 @@ import { createStore, applyMiddleware, compose } from 'redux';
 import { routerMiddleware } from 'react-router-redux';
 import { createEpicMiddleware } from 'redux-observable';
 import createHistory from 'history/createBrowserHistory';
-import rootReducer from './reducers.js';
-import rootEpic from './epics.js';
+import rootReducer from './reducers/index.js';
+import rootEpic from './epics/index.js';
 
 
 export const history = createHistory();

+ 3 - 2
utils/exampleComponent.js

@@ -1,16 +1,17 @@
 
 import React from 'react';
 import { connect } from 'react-redux';
+//import * as actions from '../actions.js';
 
 
-function Example({}) {
+function Example() {
     return <div>
             Example
         </div>;
 }
 
 
-function stateToProps({}) {
+function stateToProps() {
     return {};
 }
 function dispatchToProps(dispatch) {

+ 1 - 1
utils/reduxadder.sh

@@ -105,7 +105,7 @@ case "$addwhat" in
             #TODO: add components folder if not present (with user confirmation?)
             echo "need components folder (for now)"
         fi
-        echo "added component $name to components/ and components/index.js"
+        echo "added component $name to components/"
         ;;