react-native-switch-selector icon indicating copy to clipboard operation
react-native-switch-selector copied to clipboard

'SwitchSelector' cannot be used as a JSX component.

Open CarrionB opened this issue 2 years ago • 3 comments

Welp, I was just trying to replicate the examples, but this SwitchSelector is not working for me

import SwitchSelector from 'react-native-switch-selector';
...
const Homescreen =() => {
  ...
  const options = [
    {label: '01:00', value: '1'},
    {label: '01:30', value: '1.5'},
    {label: '02:00', value: '2'},
  ];
  return (
  ...`
         <SwitchSelector
            options={options}
            initial={0}
            onPress={value => console.log(`Call onPress with value: ${value}`)}
          />
  )
  ...
}

Error:

JSX element class does not support attributes because it does not have a 'props' property.ts(2607) 'SwitchSelector' cannot be used as a JSX component. Its instance type 'SwitchSelector' is not a valid JSX element. Type 'SwitchSelector' is missing the following properties from type 'ElementClass': context, setState, forceUpdate, props, refsts(2786)

CarrionB avatar Aug 23 '22 19:08 CarrionB

Same issue here. Any update? @jkdrangel

JadeJDoucet avatar Oct 21 '22 17:10 JadeJDoucet

My workaround for now is to downgrade to v2.1.4.

rnigro-rwb avatar Nov 11 '22 15:11 rnigro-rwb

I extract the index to a function component with typescript, see below. https://gist.github.com/ArthurAssuncao/ebe852e5d7e093389daa2a474e41741b

ArthurAssuncao avatar Feb 05 '23 20:02 ArthurAssuncao