question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating class from JS for passing to third party components

See original GitHub issue

Is there any possibility to create classes from within JS to pass to third party components like e.g. CSSTransitionGroup or react-virtualized? I’m looking for something like the following:

const onEnterClass = styled.className`
   background-color: red;
`;

// This className can now be passed to third party components
<CSSTranstitionGroup
    transitionName={{
        enter: onEnterClass,
  }} />

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kittencommented, Jun 22, 2017

To add to this, use a “magic string” constant like const onEnterClass = '.is-entering', since Math.random is problematic in combination with SSR.

0reactions
okcokercommented, Aug 18, 2017

@k15a I think that is indeed the correct function but doing const LibraryButton = Button.withComponent(LibraryComponent) doesn’t account for the whatever attribute. Is the only way to have LibraryComponent have the same styles as <Button whatever /> to have a separate extended component?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to customize your third party React components
Start by creating a wrapper component CustomizedTypeahead and replace Typeahead with it. This wrapper component has no effect for now. It's ...
Read more >
Passing a parameter to through a 3rd party function with a ...
I have a class which manages a callback, it gets triggered, and I want to trigger some code from inside the class again....
Read more >
Supply css class to 3rd party lib without using the name ...
I just want to migrate all CSS usage to styled components. :D. Styled components sits in the middle, why can't we just generate...
Read more >
How To Create Wrapper Components in React with Props
To create wrapper components, you'll first learn to use the rest and spread operators to collect unused props to pass down to nested...
Read more >
Integration of third-party libraries · React in patterns - GitBook
That's why integrating of third-party components may be tricky. In this section we will see how to mix React and jQuery's UI plugin...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found