You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by gi...@git.apache.org on 2017/10/04 08:10:28 UTC

[GitHub] dennybiasiolli opened a new issue #3589: Warning during assets tests: Failed prop type: Invalid prop `value` supplied to `Control`.

dennybiasiolli opened a new issue #3589: Warning during assets tests: Failed prop type: Invalid prop `value` supplied to `Control`.
URL: https://github.com/apache/incubator-superset/issues/3589
 
 
   **TLDR**
   
   `Control` receive `value` prop of type `function`, resulting in a warning during tests. How can we solve this? I suggest to add `PropTypes.func` to that prop, what do you think?
   
   **Details**
   
   It seems that some prop of type `function` are passed to the component `Control` via `ControlPanelsContainer` tests which takes default `form_data` property from `javascripts/explore/stores/store.js` with `getFormDataFromControls(defaultControls)`, resulting in a warning during yarn tests.
   `defaultControls` value is in `javascripts/explore/stores/controls.jsx` exported in `const controls`.
   
   `defaultControls` is used only in `ControlPanelsContainer` tests, but if we try to change [javascripts/explore/stores/store.js#L119](https://github.com/apache/incubator-superset/blob/master/superset/assets/javascripts/explore/stores/store.js#L119) in this way:
   ```
   const defaultControls = Object.assign({}, controls);
   Object.keys(controls).forEach((f) => {
     - defaultControls[f].value = controls[f].default;
     + if (typeof controls[f].default === 'function') {
     +   defaultControls[f].value = controls[f].default();
     + } else {
     +   defaultControls[f].value = controls[f].default;
     + }
   });
   ```
   it gives this error:
   ```
   /Users/denny/git/hacktoberfest/superset/superset/assets/javascripts/explore/stores/controls.jsx:138
           return c.options && c.options.length > 0 ? [c.options[0].metric_name] : null;
                   ^
   
   TypeError: Cannot read property 'options' of undefined
   ```
   
   changing `javascripts/explore/components/Control.jsx` in this way:
   ```
     value: PropTypes.oneOfType([
       PropTypes.string,
       PropTypes.number,
       PropTypes.bool,
   -     PropTypes.array]),
   +     PropTypes.array,
   +     PropTypes.func]),
   ```
   removes the issue, but is this the correct way?
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services