-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Add redux #1130
WIP: Add redux #1130
Conversation
A few thoughts as I read this code, and various docs and issues
|
…tate Sadly the syntax isn't a perfect match for connect: `connectWithStore(MyComponent, mapStateToProps, mapDispatchToProps)` not `connect(mapStateToProps, mapDispatchToProps)(MyComponent)`
- Export RootReducer as default - Import RootReducer rather than require - Replace Form with forms in root reducer - Add some junk default state - Output junk default state in ush logo component
@crcommons I pushed a couple of commits they
I figured you probably didn't want 'RootReducer' at the top? and renamed |
@@ -0,0 +1,18 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure where to put this, so I started a react-transition
folder. Maybe it should just be in common/
or common/react-transition
return (props) => { | ||
// Get the injector + store at render time | ||
// Otherwise it happens before the angular app is set up | ||
const injector = angular.element(document).injector(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty gross but it works :)
|
||
MyComponent.propTypes = { | ||
foo: PropTypes.number.isRequired, | ||
baz: PropTypes.number.isRequired | ||
}; | ||
|
||
export default connectWithStore(MyComponent, mapStateToProps, mapDispatchToProps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't figure out if it was possible to make this work with connect style syntax ie.
connect(mapStateToProps, mapDispatchToProps)(MyComponent)
so for now it has the component as the first prop instead.
} | ||
} | ||
|
||
export const getFormsFromState = state => state.forms.forms; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of a tangent: but I always find it weird that the mappers selectors for a particular reducer have to know what namespace this reducer is used under. ie. if you change the name of forms
in rootReducer, this code breaks. I don't know if theres a standard solution for that at all, ie only passing the forms
part of state to this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done some research on this and am really not sure. Adding it as an issue to refactor later.
@@ -17,5 +17,5 @@ <h1 class="mode-context-title"><a href="/" ng-bind="nav.site.name"></a></h1> | |||
<!-- <saved-search-create></saved-search-create> --> | |||
<mode-context-form-filter></mode-context-form-filter> | |||
</div> | |||
<my-component foo=3 baz=2></my-component> | |||
<my-component store={store} foo=3 baz=2></my-component> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this - but we shouldn't need to pass in store here. It might break things
@@ -38,6 +40,7 @@ function ( | |||
$scope.logout = Authentication.logout; | |||
$scope.register = Registration.openRegister; | |||
$scope.intercomAppId = $window.ushahidi.intercomAppId; | |||
$scope.store = $ngRedux; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove this.
feat: Add routing using a wrapper controller
Made it so that Jest isn't mad at angular and now tests are passing
Checking for store and reassigning props broke connect component; removed and just using plain component instead
test(ush-logo test files): got tests working with store data
…ngular/jest incompatibility Link.test.jsx
event is never received in tests
Mock state and validate calls to state.go
Migration/link api
.gitignore
Outdated
@@ -23,3 +23,4 @@ server/www/img/icons/ | |||
server/www/ | |||
app/locales/ | |||
package-lock.json | |||
app.stats.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that be app/stats.html ?
app/app.js
Outdated
require('ng-redux'); | ||
const thunk = require('redux-thunk'); | ||
import RootReducer from './rootReducer'; | ||
// import { combineReducers } from 'redux'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean up the comments?
app/app.js
Outdated
@@ -18,6 +18,15 @@ require('angular-nvd3/src/angular-nvd3'); | |||
require('angular-cache'); | |||
require('angular-linkify'); | |||
|
|||
require('redux'); | |||
require('ng-redux'); | |||
const thunk = require('redux-thunk'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not using thunk yet right?
app/app.js
Outdated
@@ -18,6 +18,15 @@ require('angular-nvd3/src/angular-nvd3'); | |||
require('angular-cache'); | |||
require('angular-linkify'); | |||
|
|||
require('redux'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to require redux? or just ng-redux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor clean up requested in comments.
Just clean those up and this can land
…er because app.js just simply doesn't work with new linting.
This pull request makes the following changes:
Testing checklist:
Go to home page and confirm you see in the mode bar: "junk", "Foo: 3", and "Baz: 2"
Go to "settings/testroute/1, click the "Click Me" link. You should be taken to data view
I certify that I ran my checklist
Fixes ushahidi/platform#2907
Fixes ushahidi/platform#2826
Ping @ushahidi/platform