Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production build: cannot read properties of undefined (reading 'list') #26

Open
juiceo opened this issue Nov 29, 2023 · 1 comment
Open

Comments

@juiceo
Copy link

juiceo commented Nov 29, 2023

We have a strange issue using this lib, which is only reproducible in our production builds:

TypeError: Cannot read properties of undefined (reading 'list')
    at react-anchorme.esm.js:1:1275
    at react-anchorme.esm.js:1:1550
    at Object.useMemo (react-dom.production.min.js:184:189)
    at Er.useMemo (react.production.min.js:25:208)
    at react-anchorme.esm.js:1:1530
    at eK (react-dom.production.min.js:167:137)
    at s$ (react-dom.production.min.js:197:258)
    at Vge (react-dom.production.min.js:195:204)
    at dre (react-dom.production.min.js:194:176)
    at lbe (react-dom.production.min.js:297:71)
o$ @ react-dom.production.min.js:189

which I can pinpoint to line 16 in AnchorMe.tsx:

import React, { useCallback, useMemo } from 'react'
import anchorme from 'anchorme'

import { AnchorProps, LinkComponent } from './types'
import { Link } from './Link'

type Props = {
	children: string
	linkComponent?: LinkComponent
} & AnchorProps

const Anchorme = ({ children, ...rest }: Props) => {
	const text = children

	const parse = useCallback(() => {
		const matches = anchorme.list(text) // <- This right here
		if (matches.length === 0) return text

...

What gives? It's as if the anchorme package isn't bundled for production?

Environment:

  • Build system: Vite
  • react-anchorme version: 4.0.1
  • react version: 18.2.0
@juiceo
Copy link
Author

juiceo commented Nov 29, 2023

Was able to resolve the issue by downgrading react-anchorme to 3.0.0, so seems like there is something off with the 4.0.1 version at least 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant