Closed maikdiepenbroek closed 7 years ago
@maikdiepenbroek Please provide more debug info, namely, please JSON.stringify()
the action that you are trying to convert. When I have that, it should be a quick fix.
Please include full error stack trace too. Uncaught TypeError: f is not a function
sounds unlikely to originate from redux-convention
since it does not define or call a function with name "f".
Uncaught TypeError: f is not a function(anonymous function)
@ compose.js?3259:20(anonymous function)
@ compose.js?3259:19(anonymous function)
@ applyMiddleware.js?3eb1:52(anonymous function)
@ configureStore.js?ea01:61(anonymous function)
@ bundle.js:5165__webpack_require__
@ bundle.js:510fn
@ bundle.js:76(anonymous function)
@ index.react.js?e275:32(anonymous function)
@ index.react.js?e275:52(anonymous function)
@ index.react.js?e275:70(anonymous function)
@ bundle.js:619__webpack_require__
@ bundle.js:510fn
@ bundle.js:76(anonymous function)
@ bundle.js:540__webpack_require__
@ bundle.js:510(anonymous function)
@ bundle.js:533(anonymous function)
@ bundle.js:536
reducer = combineReducers(reducers);
state = Immutable.Map({});
state = reducer(state, {
name: `CONSTRUCT`
});
store =
applyMiddleware(
thunkMiddleware,
convention.fromCCAtoFSA,
logger
)(createStore)(reducer, state);
export default store;
What im trying to do is getting my CCA actions to transform so that redux 3.0.0 doesn't get all pissed off.
Are you using
import {
middleware as convention
} from 'redux-convention';
to load convention.fromCCAtoFSA
?
I will build a repository and try to replicate this behaviour.
Yes sir! Sorry i forgot to include that in my code example
Any update on this ?
It is not going to happen before the end of the day. I am in process of updating https://github.com/gajus/react-css-modules. However, you can speed up things if you create a repository that would allow me to quickly replicate the issue, e.g. https://github.com/gajus/eslint-issue-3474
@gajus No problem, for me to create a repo to reproduce the issue would take longer then waiting.
@gajus Any luck ?
There is a work around for this specific problem, but the whole setup will not work either way with redux 3.0.0
I will explain in a moment why.
You could have additional middleware functions which wrap the converters.
import {
middleware as convention
} from 'redux-convention';
import {
combineReducers
} from 'redux-immutable';
import reducers from "./my_reducers.jsx";
let rootReducer = combineReducers(reducers);
let fromCCAtoFSA = (store) => (next) => (action) => {
return next(convention.fromCCAtoFSA(action));
};
let fromFSAtoCCA = (store) => (next) => (action) => {
return next(convention.fromFSAtoCCA(action));
};
const createStoreWithMiddleware = applyMiddleware(
fromCCAtoFSA,
thunkMiddleware,
promiseMiddleware,
loggerMiddleware,
fromFSAtoCCA
)(createStore);
const store = createStoreWithMiddleware(rootReducer, initialState);
This will fix the "f()" function problem, but you will see this error reported by redux:
Error: Actions may not have an undefined "type" property. Have you misspelled a constant?
In this case you could try to add one more middleware function at the bottom which could look like this
let addTypeToAction = (store) => (next) => (action) => {
let result;
let updatedAction;
updatedAction = Object.assign({}, action, {type: action.name});
result = next(updatedAction);
return result;
};
but then you will end up with validation error from canonical-reducer-composition-validator which is used by redux-immutable which looks like this:
Error: Action definition object must not define unknown properties. "type" is an unknown property
My suggestion would be to simply adapt the CCA standard to use "type" despite the fact that it's a bad name. Otherwise CCA might have problems with getting some more traction.
@pbc Thats correct.
The plan is:
This is at the top of the priority list, as it is the only thing stopping the project I am working with from upgrading to 3.*.
@gajus sounds great :) thx a lot for your work on these projects.
Thanks for making it a bit more clear for me By using that code sample :)! I've managed to get the same state as you. And @gajus thanks so much for all the effort. I would be more than willing to help if i knew exactly what needed to be done. If you could explain the steps a bit more clear then i will get to work on it! Op di 22 sep. 2015 om 17:43 schreef Pawel Barcik notifications@github.com
@gajus https://github.com/gajus sounds great :) thx a lot for your work on these projects.
— Reply to this email directly or view it on GitHub https://github.com/gajus/redux-convention/issues/1#issuecomment-142328500 .
Met vriendelijke groet,
Maik Diepenbroek
When applying the middleware functions: convention.fromCCAtoFSA, and convention.fromFSAtoCCA, i get the error as described in the title.
This does not seem to fix the problem after upgrading to redux 3.0.0