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.

@mitchellhamilton hey, I’m not sure if this is possible because I don’t know the exact internals of emotion, but from a conceptual level this might make sense.

I’m wondering if we could do something like


const MyComponent = props => {
   const theme = useContext(ThemeContext);
   const className = useCss({color: theme.red});
   return (
     <div className={className}>
       MyComponent
     </div>
    );
}

any thoughts?

from a birds eye view, some thoughts here are, you now don’t need to worry about shouldForwardProp you don’t need to interpolate with color: ${props => props.theme.red} and the entire component doesn’t need to be wrapped, if the ref needs to be forwarded, then you just use forwardRef, etc.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
Andaristcommented, Nov 3, 2019

We’ll rethink how this problem can be handled right now. We are working on a v11, so we’d like to address problems like this. The solution is not obvious - so no promises yet, but please know that we are going to think about this.

2reactions
ekaradoncommented, Jun 18, 2019

Following the migration from emotion@9 to emotion@10 with react-toastify, I am also facing an issue here. I have the following hook:

function useSuccessNotification(valid, message) {
    useEffect(() => {
        if (valid) {
            toast.success(message, {
                className: css({
                    ...
                })
            });
        }
    }, [message, valid]);
}

Far away from any render, So I cannot use the ClassNames render prop tip. A hook would be really nice.

Do you see how I could make it work without using deprecated library?

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-use/useCss.md at master - GitHub
useCss. React UI hook that changes CSS dynamically. Works like "virtual CSS" — it re-renders only CSS rules that change. It is different...
Read more >
useCss hook - Kremling
The useCss hook allows you to write css that will only apply to your component and to its children. ... In this example,...
Read more >
use-css - npm
Silly React hook for CSS Demo on CodeSandbox. install. npm install use-css. usage. import useCSS from 'use-css'. function Oopsy(props) {.
Read more >
Know about the useInsertionEffect hook in React 18
The useInsertionEffect hook in React 18 is mostly for CSS-in-JS libraries for inserting global DOM nodes like 'style' or SVG 'defs' in the ......
Read more >
useCss | API Reference - Nightwatch.js
useCss (). Sets the locate strategy for selectors to css selector , therefore every following selector needs to be specified as css. Parameters ......
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