idx() callbacks may only access properties on the callback parameter!
Closed this issue · 1 comments
xareelee commented
I've reported this issue on flowtype: facebook/flow#4729
I also create an issue here.
The following code raises a flowtype error when using idx with immutable.js:
// `state` is obtained from redux store
// `state.user` is an immutable object; you need to use `getIn()` to access properties
const token = idx(state, _ => _.user.getIn(['userInfo', 'token']));
The flowtype shows the error:
81: const countryCode = idx(state, _ => _.country.getIn(['selectCountry', 'countryCode']));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. idx() callbacks may only access properties on the callback parameter!
I need to change code to this to suppress flowtype warnings:
const tokenS = idx(state, _ => _.user.getIn);
const token = (tokenS) ? tokenS(['userInfo', 'token']) : undefined;
It makes no sense to write such code.
yungsters commented
Call expressions are no longer supported from within idx
. Obsoleted by v2.0.0.