Code Monkey home page Code Monkey logo

react-anchorme's People

Contributors

dependabot[bot] avatar potty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-anchorme's Issues

Passing options to anchorme.js?

Hi

Is there a way to add options, passed to anchorme.js ?

Say I'd like to do
<Anchorme options={{truncate: 6}}>text</Anchorme>

Mixing inner text and parameters causes error

Great library!
One issue I'm seeing is that if you have both normal text and bracketed inner parameters passed as children the component throws various errors.

Example 1:
testa.com {"testb.com"}

Example 2, note the spaces around the brackets:
{"testa.com"}

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

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

Pass thru Anchorme options

Hi @potty, thanks so much for creating this excellent wrapper! Curious if there is a way to pass through the props to anchorme to take full advantage of the Anchorme library?

Add license

Hey, nice component! We would like to use it in one of our projects, but it looks like you haven't explicitly defined a license for this project so it would go against our open source dependency guidelines. Could you add one? :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.