There is problem with new version of Emotion for this episode. Viewers have reported that Reflexbox doesn't play well with it.
There are two possible solutions:
- Check package.json used in this video
- Set Emotion plugins versions locally in your package.json (@emotion/core, @emotion/styled, emotion-theming)
- Remove node_modules
- Run
npm install
Now you have downgraded Emotion to version 10. And Reflex box should now work as expected.
- Install @emotion/react
npm install @emotion/react
- In your _app.js import
ThemeProvider
from@emotion/react
instead ofemotion-theming
like this:
import { ThemeProvider } from '@emotion/react'
Now Emotion should work, however there are some problems. First of all for some reason theme
that you define on ThemeProvider
doesn't automatically apply to<Box>
and <Flex>
elements in your components. So you have to add them manually whenever you are using them in your componets. Like this:
// MyAwesomeComponent
...
import theme from '../theme/theme.js'
function MyAwesomeComponent({my, props}) {
return(
<Flex theme={theme} ...>
<Box theme={theme} ...>
Hello World
</Box>
</Flex>
)
}
...
The other thing is that breakpoints will work only in the way that I showed first in the video, so you won't be able to define them like this:
<Flex flexDirection={{ _: "column", md: "row" }}>
But instead you have to define them like:
<Flex flexDirection={['column', null, null, 'row']}>
So if you want to use Emotion 11, you will have to deal with these two things.