Code Monkey home page Code Monkey logo

react-switch-button's Introduction

react-switch-button's People

Contributors

bmaland avatar gfazioli avatar lironess avatar manuel-manoury avatar pierrefourgeaud avatar reggino avatar tappleby avatar tcw165 avatar teodortunev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-switch-button's Issues

2.0.1 issue on ES6 import

It seems that importing with ES6 doesn't work.

import SwitchButton from 'react-switch-button';

This throws the following error using webpack:

ERROR in ./~/react-switch-button/src/react-switch-button.js
Module parse failed: /vagrant/src/scripts/app/node_modules/react-switch-button/src/react-switch-button.js Unexpected token (70:8)
You may need an appropriate loader to handle this file type.

Any idea?

don't change class/color when toggled

awesome component!

i'm using the switch button in the sense of switching between two options rather than 'on/off', is there an easy way I can disable it from changing color to the 'off-state' and just keep it 'on' the whole time?

Jest Cannot find module 'react-switch-button'

@gfazioli During running tests with Jest I have the following issue Cannot find module 'react-switch-button' from ...(some js file).
Getting into source code of library under node_modules I see typo in package.json
"main": "dist/react-switch-button.min.js", , which doesn't correspond to actual name under dist folder react-switch-button.js (without min). Please fix this typo, because changing name to react-switch-button.min.js makes the tests pass.
Thanks.

Enable to make it work (dependencies problem?)

Hello,

After having done the npm install react-switch-button --save, i have those warnings :

Compiled successfully!
npm WARN [email protected] requires a peer of react@^0.14.8 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@^0.14.0 || ^15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\react-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

In my App.js class, after having import the module using
import SwitchButton from 'react-switch-button';
I just try to include it in my render function this way
<SwitchButton label="Click me" />
and i always have the same error :

InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('/static/media/react-switch-button.857546cd.jsx') is not a valid name.

Could you help me ?

Asking for appropriate loader

I am using this module into my cordova and have added dependency in package.json

"dependencies": {
        "cordova-android": "^7.0.0",
        "cordova-ios": "^4.5.4",
        "cordova-plugin-whitelist": "^1.3.3",
        "react": "^16.3.1",
        "react-dom": "^16.3.1",
        "react-redux": "^5.0.7",
        "react-switch-button": "^2.3.0",
        "redux": "^3.7.2",
        "webpack": "^4.5.0"
    }

And in this how I have used

import React from 'react'
import ImgArrow from '../../../../../img/list_arrow.png'
import style from './setting_drawable.css'
import SwitchButton from 'react-switch-button'

const SettingDrawable = (props) => {
  let type = props.Type

  if (props.Type === '' || props.Type === null) {
    // default drawable
    type = 'SELECTION_DEFAULT'
  }

  let drawable = <img className = {style.DrawableSource} src={ImgArrow} />
  if (type === 'SELECTION_DEFAULT') {
    drawable = <img className = {style.DrawableSource} src={ImgArrow} />
  } else if (type === 'TOGGLE') {
    drawable = <SwitchButton name={ props.name } checked={ props.on } />
  }

  return (
    <div className = {style.SettingDrawable}>{ drawable }</div>
  )
}

export default SettingDrawable

And while running the command npm run build which will run following part "build": "webpack --config webpack.config.js --display-error-details"

and in return I get this as stacktrace:

ERROR in ./node_modules/react-switch-button/src/react-switch-button.jsx
Module parse failed: Unexpected token (31:8)
You may need an appropriate loader to handle this file type.
|
|       return (
|         <div className={classes.join( " " ).trim()}>
|           {
|             (this.props.label.length > 0)
 @ ./www/js/components/Settings/SettingElement/SettingDrawable/SettingDrawable.js 19:25-55

I get Module parse failed: Unexpected token (31:8) when trying to load it with webpack

My project is in typescript so I don't have babel installed.

ERROR in ./node_modules/react-switch-button/src/react-switch-button.jsx
Module parse failed: Unexpected token (31:8)
You may need an appropriate loader to handle this file type.
|
|       return (
|         <div className={classes.join( " " ).trim()}>
|           {
|             (this.props.label.length > 0)
 @ ./src/Wallet.tsx 23:28-58
 @ ./src/Dashboard.tsx
 @ ./src/main.tsx
 @ multi webpack-dev-server/client?http://localhost:3300 webpack/hot/only-dev-server ./src/main

That should not matter though because it should all run from the dist files right?

Disabled

Can i disable the switch button?

No way to define id and for of the element in the component

When I am creating multiple switch-button component it generating duplicating id and for in the input and label element.
Is there any way to define it explicitly ?

<div class="rsbc-switch-button rsbc-mode-switch rsbc-switch-button-flat-round">
      <input type="checkbox" id="switch-button" name="switch-button" value="1">
      <label for="switch-button"></label>
</div>

How to import using require?

Looks like we can't import this by doing something like

var Switch = require('react-switch-button');

Throws CompileError.

CompilerError: 
.../node_modules/react-switch-button/index.html:1
<!DOCTYPE html>
^
ParseError: Unexpected token

Error: Cannot find module 'react-switch-button'

I just got this Error from the build server.
The build is done with browserify like this:

browserify browser.js -t [ babelify --presets [ es2015 react  ] ] -t brfs -t require-globify -g uglifyify -o public/js/bundle.js -v

I got this as a dependency in my package.json

  "react-switch-button": "^2.2.2",

The build server downloaded version 2.3.0

Locally with the version 2.2.2 it works.

My question is, would it be better to change the version of 2.3 to 3.0 since it may break the build process?

Prop name - label_right

The convention for components seems to be camel case for props. Can label_right be changed to labelRight? Or perhaps a more suitable name could be found.

Uncaught TypeError: Cannot read property 'createClass' of undefined

Installed fresh version from npm:

npm install react-switch-button --save

-- [email protected]

And getting "Uncaught TypeError: Cannot read property 'createClass' of undefined" on import

Importing like this:

import SwitchButton from 'react-switch-button';

also tried this according to "ReadMe":

import Select from 'react-switch-button';
import Switch from 'react-switch-button';

React.createClass is deprecated

Problem 💥

when using this component, there is a warning that React.createClass() will be removed in React version 16.

Solution 🤔

The package create-react-class should be used instead of the function from the React base package.

controlled component

Question 🤔 ❓

is there a particular reason why this component can't be a controlled component? There is a checked prop but it is set to a PropTypes.string which makes no sense. Also, this prop is never used...

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.