Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1273 | Rev 2785 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1273 Rev 1821
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { useEffect, useState } from 'react'
2
import styled, { css } from 'styled-components'
2
import styled, { css } from 'styled-components'
Línea 3... Línea 3...
3
 
3
 
4
const SwitchContainer = styled.label`
4
const SwitchContainer = styled.label`
5
  display: inline-flex;
5
  display: inline-flex;
Línea 64... Línea 64...
64
const SwitchInput = ({
64
const SwitchInput = ({
65
  label = '',
65
  label = '',
66
  isChecked: initialValue = false,
66
  isChecked: initialValue = false,
67
  setValue = () => null
67
  setValue = () => null
68
}) => {
68
}) => {
69
  const [isChecked, setIsChecked] = useState(initialValue)
69
  const [isChecked, setIsChecked] = useState(false)
Línea 70... Línea 70...
70
 
70
 
71
  const handleToggle = () => {
71
  const handleToggle = () => {
72
    setIsChecked(!isChecked)
72
    setIsChecked(!isChecked)
73
    setValue(!isChecked)
73
    setValue(!isChecked)
Línea -... Línea 74...
-
 
74
  }
-
 
75
 
-
 
76
  useEffect(() => {
-
 
77
    setIsChecked(initialValue)
74
  }
78
  }, [initialValue])
75
 
79
 
76
  return (
80
  return (
Línea 77... Línea 81...
77
    <SwitchContainer>
81
    <SwitchContainer>