Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010064
resource.jsx
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
995 B
Referenced Files
None
Subscribers
None
resource.jsx
View Options
const
React
=
require
(
"react"
);
const
CachedHttp
=
require
(
"./cached-http.js"
);
module
.
exports
=
(
{
collection
,
get_forced_filter
=
()
=>
{},
get_forced_format
=
()
=>
{},
get_id
=
props
=>
props
.
id
,
},
component
)
=>
class
Resource
extends
React
.
Component
{
constructor
()
{
super
();
this
.
state
=
{
loading
:
true
,
resource
:
null
,
};
}
componentDidMount
()
{
CachedHttp
.
get
(
`/api/v1/collections/
${
collection
}
/
${
get_id
(
this
.
props
)
}
`
,
{
filter
:
Object
.
assign
({},
get_forced_filter
(
this
.
props
)),
format
:
get_forced_format
(
this
.
props
),
}
).
then
(
resource
=>
this
.
setState
({
loading
:
false
,
resource
}));
}
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
,
Object
.
assign
({},
this
.
props
,
{
resource
:
this
.
state
.
resource
,
loading
:
this
.
state
.
loading
,
})
);
}
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 7, 19:36 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
671902
Default Alt Text
resource.jsx (995 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment