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

Add an "as" prop to customize the returned element #17

Open
mikeriley131 opened this issue Mar 3, 2023 · 0 comments
Open

Add an "as" prop to customize the returned element #17

mikeriley131 opened this issue Mar 3, 2023 · 0 comments

Comments

@mikeriley131
Copy link

Thanks for building this!
What do you think about being able to customize the returned element via something like an as prop?
I want to use this package within unordered lists to stagger the display of the list items, but wrapping the list items in the package's returned <div> creates invalid HTML.

I was thinking an as prop would be nice so you could maintain the proper markup in this situation.

Example:

<AnimationOnScroll
  animateIn="animate__fadeIn"
  as="li"
  duration={2}
  delay={index * 1000}
  animateOnce
>

You then add the as prop to the component:

as: Component

Default it to "div":

as = "div"

and then you change the component's return value to:

<Component
  ref={node}
  className={classNameProps ? `${classNameProps} ${classes}` : classes}
  style={Object.assign({}, style, styleProps)}
>
  {children}
</Component>

What do you think?
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