New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not define components during render #11536
Comments
Hey @jbrodriguez! Thanks for opening the issue. It seems that the issue doesn't contain a link to a repro. The best way to get attention to your issue is to provide an easy way for a developer to reproduce the issue. You can provide a repro using any of the following:
A snack link is preferred since it's the easiest way to both create and share a repro. If it's not possible to create a repro using a snack, link to a GitHub repo under your username is a good alternative. Don't link to a branch or specific file etc. as it won't be detected. Try to keep the repro as small as possible by narrowing down the minimal amount of code needed to reproduce the issue. Don't link to your entire project or a project containing code unrelated to the issue. See "How to create a Minimal, Reproducible Example" for more information. You can edit your original issue to include a link to the repro, or leave it as a comment. The issue will be closed automatically after a while if you don't provide a repro. |
The versions mentioned in the issue for the following packages differ from the latest versions on npm:
Can you verify that the issue still exists after upgrading to the latest versions of these packages? |
thank you, the react-native-tab-view component is not active in relation to the issue presented |
You're getting warning from the ESLint rules you're using, it's not a bug in React Navigation. The options like |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
Hello, the same happens when you use |
Yes |
Care to elaborate why? |
Components are used like |
Being React Components functions that takes props and returns JSX I don't understand what the difference is and above all why the warning should be a false positive. |
@VariabileAleatoria returning JSX doesn't make something a component. whether something is a component or not doesn't depend how the definition looks, but how it is used - if it's not used like |
I fixed this warning passing a function to tabBarIcon instead of a component: const renderTabIcon = (name: string, color: string) => {
return <Icon name={name} size={25} color={color} />;
};
<Tab.Screen
options={{
title: 'Home',
tabBarIcon: ({color}) => renderTabIcon('home-outline', color),
}}
name="HomeScreen"
component={HomeScreen}
/> |
Current behavior
the app works, but we get an eslint warning
this is the code
i need to pass the route.name in order to set the icon and need
props
due to the focused propertyany thoughts ?
Expected behavior
we shouldn't receive an eslint warning
Reproduction
https://github.com/react-navigation/react-navigation
Platform
Packages
Environment
The text was updated successfully, but these errors were encountered: