GithubHelp home page GithubHelp logo

Comments (3)

vdanchenkov avatar vdanchenkov commented on May 4, 2024 1

How does it work with component wrapping? This way?

const StyledBox = styled(Box).withConfig({ displayName: 'StyledBox', componentId: 'Button_asdf123' })`
  styles: here;
`

from babel-plugin-styled-components.

vdanchenkov avatar vdanchenkov commented on May 4, 2024 1

@mxstbr Thanks for the explanation. I'll update it in a nearest time.

from babel-plugin-styled-components.

mxstbr avatar mxstbr commented on May 4, 2024

To elaborate a bit on why this is a necessary change, on the web we can transpile our styled calls like so:

// before
const Box = styled.div``
// after
const Box = styled({ target: 'div' })``

Which is what we do right now! The issue is, that doesn't work on ReactNative. Imagine this:

// before
const Box = styled.View``

Transpiling it to this breaks, because in ReactNative there are no string primitives:

// after
const Box = styled({ target: 'View' })`` // 🚫 Breaks

Instead, we'd have to transpile it to this:

// after
import { View } from 'react-native'
const Box = styled({ target: View })``

Which would have been a pain to do!

So, with the new syntax we fully avoid this issue, because no matter what the user does this always works:

const Box = styled.div.withConfig({ })`` // That works perfectly fine
const Box = styled.View.withConfig({ })`` // That works too, no import needed!
const Box = styled(OtherComp).withConfig({ })`` // No problem
const Box = styled('div').withConfig({ })`` // No problem either

Does that explain better why we need to switch?

from babel-plugin-styled-components.

Related Issues (20)

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.