fix: react router nopeification

This commit is contained in:
cha0s 2022-03-20 00:52:24 -05:00
parent c5cd656a77
commit ce72516c3c
2 changed files with 6 additions and 7 deletions

View File

@ -9,7 +9,6 @@ import {
useFlecks, useFlecks,
useState, useState,
} from '@flecks/react'; } from '@flecks/react';
import {useParams} from '@flecks/react/router';
import { import {
Tab, Tab,
Tabs, Tabs,
@ -23,9 +22,9 @@ import View from './view';
const EntityComponent = ({ const EntityComponent = ({
resource, resource,
path, path,
uri,
}) => { }) => {
const flecks = useFlecks(); const flecks = useFlecks();
const {uri} = useParams();
const {Entity, EntityList} = flecks.get('$avocado/resource.resources'); const {Entity, EntityList} = flecks.get('$avocado/resource.resources');
const [entity, setEntity] = useState(); const [entity, setEntity] = useState();
useEffect(() => { useEffect(() => {
@ -89,10 +88,11 @@ EntityComponent.defaultProps = {
EntityComponent.displayName = 'EntityComponent'; EntityComponent.displayName = 'EntityComponent';
EntityComponent.propTypes = { EntityComponent.propTypes = {
path: PropTypes.string,
resource: PropTypes.shape({ resource: PropTypes.shape({
traits: PropTypes.shape({}), traits: PropTypes.shape({}),
}).isRequired, }).isRequired,
path: PropTypes.string, uri: PropTypes.string.isRequired,
}; };
export default EntityComponent; export default EntityComponent;

View File

@ -4,14 +4,12 @@ import {
PropTypes, PropTypes,
React, React,
} from '@flecks/react'; } from '@flecks/react';
import {useParams} from '@flecks/react/router';
import useResourceController from '../../hooks/use-resource-controller'; import useResourceController from '../../hooks/use-resource-controller';
import locals from './index.module.scss'; import locals from './index.module.scss';
const Resource = ({resource}) => { const Resource = ({resource, uri}) => {
const {uri} = useParams();
const {Component} = useResourceController(uri); const {Component} = useResourceController(uri);
let displayedUri = basename(uri); let displayedUri = basename(uri);
if (0 === displayedUri.indexOf('index')) { if (0 === displayedUri.indexOf('index')) {
@ -19,7 +17,7 @@ const Resource = ({resource}) => {
} }
return ( return (
<div className={locals.resource}> <div className={locals.resource}>
<Component resource={resource} /> <Component resource={resource} uri={uri} />
<div className={locals.uri}>{displayedUri}</div> <div className={locals.uri}>{displayedUri}</div>
</div> </div>
); );
@ -30,6 +28,7 @@ Resource.displayName = 'Resource';
Resource.propTypes = { Resource.propTypes = {
// eslint-disable-next-line react/forbid-prop-types // eslint-disable-next-line react/forbid-prop-types
resource: PropTypes.any.isRequired, resource: PropTypes.any.isRequired,
uri: PropTypes.string.isRequired,
}; };
export default Resource; export default Resource;