Catch error in RuleLink

pull/2092/head
Jérémy Rialland 2022-04-07 12:17:05 +02:00 committed by Johan Girod
parent b85746de52
commit babf0fb0f6
3 changed files with 20 additions and 4 deletions

View File

@ -16,6 +16,15 @@ export default function RuleLink(
const sitePaths = useContext(SitePathsContext)
const engine = useContext(EngineContext)
try {
engine.getRule(props.dottedName)
} catch (error) {
// eslint-disable-next-line no-console
console.error(error)
return null
}
return (
<EngineRuleLink
{...props}

View File

@ -10,7 +10,7 @@ import { DottedName } from 'modele-social'
import RuleLink from '../../RuleLink'
import { Highlight } from '../Hightlight'
type Hit = AlgoliaHit<{ objectID: DottedName; namespace?: string }>
type THit = AlgoliaHit<{ objectID: DottedName; namespace?: string }>
const StyledRuleLink = styled(RuleLink)`
${SmallBody}, ${Body} {
@ -42,7 +42,7 @@ const HitContainer = styled.li`
}
`
const Hit = (hit: Hit) => {
const Hit = (hit: THit) => {
return (
<HitContainer>
<StyledRuleLink dottedName={hit.objectID}>
@ -89,7 +89,14 @@ const InfiniteHits = styled.div`
}
`
const Hits = connectInfiniteHits(({ hits, hasMore, refineNext }) => {
interface IHits {
hits: THit[]
hasMore: boolean
hasPrevious: boolean
refineNext: () => void
}
const Hits = connectInfiniteHits(({ hits, hasMore, refineNext }: IHits) => {
const { t } = useTranslation()
return (

View File

@ -95,7 +95,7 @@ export function SimpleField({
const labelId = useSSRSafeId()
const targetUnit = useSelector(targetUnitSelector)
console.log(dottedName, evaluation)
if (evaluation.nodeValue === null) {
return null
}