fix: URI not required

This commit is contained in:
cha0s 2022-03-20 15:15:04 -05:00
parent 0f9e821426
commit b350b78f64

View File

@ -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;