question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switch using deprecated props according to react native

See original GitHub issue

**Explain what you did** Using listItem in flatList <ListItem roundAvatar title={${item.name}} titleStyle={{ paddingLeft: 20, fontSize: 16 }} rightTitle={item.mode} rightTitleStyle={Styles.flatListItemRightTitle} leftIcon={<Icon name={item.icon} size={23} color={colors.primary} />} hideChevron switchButton={item.switch} switched={item.switched} switchOnTintColor={colors.primary} switchThumbTintColor={colors.primary} switchTintColor={colors.background} containerStyle={{ borderBottomWidth: 0, marginTop:15, marginBottom: 15 }} onPress={item.onPress} onSwitch={item.onSwitch} /> Expected behaviour A switch in listItem working with no yellow box warnings

Describe the bug Deprecated props on switch warning This is the current implementation @xavier-villelegier which is causing the deprecated warning. According to react native 0.57.xx documentation, tintColor changes to trackColor e.t.c Switch props should be updated in this library’s implementation of the switch in listItem.js

{switchButton && hideChevron && ( <View style={styles.switchContainer}> <Switch onValueChange={onSwitch} disabled={disabled ? disabled : switchDisabled} onTintColor={switchOnTintColor} thumbTintColor={switchThumbTintColor} tintColor={switchTintColor} value={switched}] /> </View> )}

To Reproduce We highly recommend that you re-create the bug on Snack. If not, list the steps that a reviewer can take to reproduce the behaviour:

Steps

  1. Add listItem to FlatList
  2. Use any of the switch props for the listItem
  3. Open flatList
  4. See warning

Possible Solution Update Switch props to use new props

Your Environment (please complete the following information):

software version
react-native-elements 0.19.1
react-native 0.57.5
yarn v1.12.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
xavier-villelegiercommented, Nov 29, 2018

@iamdarknight Okay I see that they have deprecated these three props: onTintColor, thumbTintColor and tintColor.

As we’re working on the v1, we deploy a v0.19.x only if it’s a critical bug, which is not the case here for now. Moreover, the ListItem has been fully rewritten, and much more modular, as you can pass anything you want to the Switch component, so this won’t happen anymore in the v1.

You can test it out by running npm i -S react-native-elements@beta, and have a look at the v1.0.0-beta7 ListItem documentation

1reaction
xavier-villelegiercommented, Nov 29, 2018

@iamdarknight You can go through the release notes of the betas to have an idea of the changes, but you can also wait for the official v1, we’ll surely do a migration guide 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

ViewPropTypes will be removed from React Native. Migrate to ...
Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. WARN ColorPropType will be removed from React Native.
Read more >
ViewPropTypes will be removed from React ... - Stack Overflow
Solution: Install patch-package into your project, as per the instructions. Install deprecated-react-native-prop-types by running npm ...
Read more >
Direct Manipulation - React Native
It is sometimes necessary to make changes directly to a component without using state/props to trigger a re-render of the entire subtree.
Read more >
deprecated-react-native-prop-types - npm
Deprecated prop -types from React Native. ... Start using deprecated-react-native-prop-types in your project by running `npm i ...
Read more >
Introducing Hooks - React
React Native has supported Hooks since the 0.59 release of React Native. ... with React for a while, you may be familiar with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found