Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1263014
resource.jsx
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
resource.jsx
View Options
const
React
=
require
(
"react"
);
const
SingleResourceAPI
=
require
(
"./api/single-resource-api.js"
);
const
default_forced_query
=
props
=>
({
filter
:
{},
format
:
{},
sort
:
{},
});
module
.
exports
=
(
{
collection
,
get_forced_query
=
default_forced_query
,
get_id
=
props
=>
props
.
id
,
resource_api_class
=
SingleResourceAPI
,
},
component
)
=>
class
Resource
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
resourceAPI
=
new
resource_api_class
(
collection
,
get_id
(
this
.
props
),
{
filter
:
{
...
get_forced_query
(
this
.
props
).
filter
,
},
format
:
get_forced_query
(
this
.
props
).
format
,
}
);
this
.
state
=
{
resourceData
:
null
,
};
this
.
resourceAPI
.
on
(
"change"
,
newData
=>
this
.
setState
({
resourceData
:
newData
})
);
this
.
resourceAPI
.
load
();
}
componentWillUnmount
()
{
this
.
resourceAPI
.
removeAllListeners
();
}
render
()
{
if
(
!
get_id
(
this
.
props
))
{
throw
Error
(
"Please provide the resource id as an 'id' prop or provide the 'get_id' prop"
);
}
return
React
.
createElement
(
component
,
{
...
this
.
props
,
loading
:
this
.
resourceAPI
.
loading
,
resourceAPI
:
this
.
resourceAPI
,
resourceData
:
this
.
state
.
resourceData
,
});
}
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 24, 15:16 (13 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
599686
Default Alt Text
resource.jsx (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment