Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
e9fe8f47
Verified
Commit
e9fe8f47
authored
Apr 13, 2020
by
Florent Chehab
Browse files
feat(frontend): new NetWrapParam params
* will enable smart reload
parent
0b7be06e
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/hoc/withNetworkWrapper.jsx
View file @
e9fe8f47
...
...
@@ -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.
"
);
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment