fix: URI not required
This commit is contained in:
parent
0f9e821426
commit
b350b78f64
|
@ -27,13 +27,17 @@ const EntityComponent = ({
|
|||
const flecks = useFlecks();
|
||||
const {Entity, EntityList} = flecks.get('$avocado/resource.resources');
|
||||
const [entity, setEntity] = useState();
|
||||
const dep = uri ? join(uri, path) : path;
|
||||
useEffect(() => {
|
||||
setEntity();
|
||||
const loadEntity = async () => {
|
||||
const entity = await Entity.load({
|
||||
const json = {
|
||||
...resource,
|
||||
uri,
|
||||
});
|
||||
};
|
||||
if (uri) {
|
||||
json.uri = uri;
|
||||
}
|
||||
const entity = await Entity.load(json);
|
||||
entity.list = new EntityList();
|
||||
setEntity(entity);
|
||||
};
|
||||
|
@ -45,7 +49,7 @@ const EntityComponent = ({
|
|||
setEntity();
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [Entity, join(uri, path)]);
|
||||
}, [Entity, dep]);
|
||||
useEffect(() => {
|
||||
const load = async () => {
|
||||
await entity?.load(resource);
|
||||
|
@ -83,6 +87,7 @@ const EntityComponent = ({
|
|||
|
||||
EntityComponent.defaultProps = {
|
||||
path: '/',
|
||||
uri: null,
|
||||
};
|
||||
|
||||
EntityComponent.displayName = 'EntityComponent';
|
||||
|
@ -92,7 +97,7 @@ EntityComponent.propTypes = {
|
|||
resource: PropTypes.shape({
|
||||
traits: PropTypes.shape({}),
|
||||
}).isRequired,
|
||||
uri: PropTypes.string.isRequired,
|
||||
uri: PropTypes.string,
|
||||
};
|
||||
|
||||
export default EntityComponent;
|
||||
|
|
Loading…
Reference in New Issue
Block a user