ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 415 forks source link

Icons are assumed to be Image components #68

Closed jadnco closed 6 years ago

jadnco commented 8 years ago

It would be nice to be able to render any component with the renderIcon and renderSelectedIcon properties. Using <Text /> or <View /> works fine, but this warning pops up:

Warning: Failed propType: Invalid props.style key `tintColor` supplied to `View`

I ran into this while implementing react-native-vector-icons - which uses <Text />.

windy commented 8 years ago

+1 I have the same problem, hope author can merge this earlier.

anywhy commented 8 years ago

+1 I have the same problem,wants help.

charlesLin commented 8 years ago

+1 The same issue. Please help.

timscott commented 8 years ago

Is there a workaround?

CaryLandholt commented 8 years ago

+1 - tried to resolve this several times, went down a rabbit hole… would really appreciate some help on this

simlegate commented 7 years ago

is there any update?

bingoyan commented 7 years ago

I use this way to solve this issue. Use renderIcon and renderSelectedIcon, then the [Warning] disappeared.

const tabBarItems = [
    { title: 'home', icon:() => <Icon name={'home'} size={30} /> , icon_selected:() => <Icon name={'home'} color = {'#4F8EF7'} size={30} /> , component: HomeContainer },
    { title: 'mark', icon:() => <Icon name={'bookmark'} size={30} />, icon_selected:() => <Icon name={'bookmark'} color = {'#4F8EF7'} size={30} /> , component: HomeContainer },
]
<TabNavigator tabBarStyle={{ height: 60 }}> 
                {
                    tabBarItems.map((controller, i) => {
                        let Component = controller.component;
                        return (
                            <TabNavigator.Item
                                key= {i}
                                selected={this.state.selectedTab === controller.title}
                                title={controller.title}
                                **renderIcon = {controller.icon}
                                renderSelectedIcon = {controller.icon_selected}**
                                onPress={() => this.setState({ selectedTab: controller.title }) }>

                                <Component navigator = {this.props.navigator} {...this.props}/>
                            </TabNavigator.Item>
                        )
                    })
                }
</TabNavigator >
timscott commented 7 years ago

Thanks @bingoyan. Works for me. Adding renderSelectedIcon for every TabNavigator.Item makes the warning go away.

ptomasroos commented 6 years ago

Will close since this issue is more than a year, feel free to a open a new if this is still a issue.