Verified Commit e9fe8f47 authored by Florent Chehab's avatar Florent Chehab
Browse files

feat(frontend): new NetWrapParam params

* will enable smart reload
parent 0b7be06e
......@@ -25,17 +25,33 @@ export class NetWrapParam {
* @param {"all"|"one"} variant - Is it a "all" or a "one" (GET all or GET one object)
* @param {string} [propKey] - On what prop is the main data mapped
* @param {RequestParams|function(props):RequestParams} [params] - RequestParams for the first request. If a function, takes as argument the props.
* @param {Object} [propTypes] - Proptypes in case the param is a function using props.
*/
constructor(
routeName,
variant,
propKey = routeName,
params = RequestParams.Builder.build()
{
propKey = routeName,
params = RequestParams.Builder.build(),
// eslint-disable-next-line react/forbid-foreign-prop-types
propTypes = {}
} = {}
) {
this.routeName = routeName;
this.variant = variant;
this.propKey = propKey;
this.params = params;
this.propTypes = propTypes;
if (process.env.NODE_ENV !== "production") {
if (typeof params === "function" && Object.keys(propTypes).length === 0) {
// eslint-disable-next-line no-console
console.error(params, propTypes);
throw new Error(
"propTypes optional argument must not be empty as params is a function taking the props of this component as argument."
);
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment