Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22396919
resource.jsx
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
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
),
{
attachments
:
get_forced_query
(
this
.
props
).
attachments
,
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
application/javascript
Expires
Fri, Nov 27, 17:01 (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1204181
Default Alt Text
resource.jsx (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline