Giter VIP home page Giter VIP logo

react-scoped's Introduction

ReactScoped

Inspired by angular style scoped

Usage

npm i react-scoped

import { ReactScoped, ViewEncapsulation } from 'react-scoped'

const styles = `
  .test {
    color: red;
  }
  .home {
    font-size: 20px;
  }
`

export default class App extends Component {
  render() {
    return (
      <ReactScoped encapsulation={ViewEncapsulation.Emulated} styles={[styles]}>
        <div className="test">
          <p className="home">Home</p>
          <SubComponent />
        </div>
      </ReactScoped>
    )
  }
}

Less

  • Webpack: raw-loader!less-loader

  • Component

import { ReactScoped, ViewEncapsulation } from 'react-scoped'
import styles from './style.less'

export default class App extends Component {
  render() {
    return (
      <ReactScoped encapsulation={ViewEncapsulation.Emulated} styles={[styles]}>
        <div className="test">
          <p className="home">Home</p>
          <SubComponent />
        </div>
      </ReactScoped>
    )
  }
}

ReactScoped

props: {
  styles?: string[]
  encapsulation?: ViewEncapsulation
}

defaultProps: {
  styles: [],
  encapsulation: ViewEncapsulation.Emulated
}

ViewEncapsulation

react-scoped's People

Contributors

doxiaodong avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

react-scoped's Issues

Build fails to minify the code from React Scoped.

Hello.
I am trying to build my react project on the server (Which runs fine locally). and i get the following error.
Pls note that it was running fine earlier before the react-scoped module was added.

Failed to minify the code from this file:

    ./node_modules/react-scoped/lib/ReactScoped.js:7

Read more here: http://bit.ly/2tRViJ9

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: node scripts/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-12-04T06_24_50_394Z-debug.log
Failed to Build the app

I have node v8.3.0 and npm v5.5.1 on the server.

What can the issue be ?

Thank you.

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.