Sign in
Log inSign up

Is there such a thing as a React Single File Component?

Will Stone's photo
Will Stone
·Sep 28, 2017

Having dipped my toe into VueJS, I have fallen in love with their SFCs. Template, Script, Style now seems like such a sensible solution to all this talk of CSS-in-JS. Has there been any discussion for such a venture in React? I can imagine it wouldn't take much to make a webpack loader to translate an ComponentName.react file:

<script>
    import React from 'react'

    const ComponentName = () => {
        return (
            <div className="ComponentName"/>
        )
    }

    export default ComponentName
</script>

<style scoped>
    .ComponentName {
        display: block;
    }
</style>
Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct