Native Base <Content/> type is not rendered
See original GitHub issueHi, I have this component:
import {
Container,
Content,
Text,
} from 'native-base';
<Container style={styles.container}>
<Content padder>
<Text testID={'emptyCasesList'}>Cases list is empty</Text>
</Content>
</Container>
But the test can’t find the ‘emptyCasesList
’ element. when I run debug.deep, I can’t see the <Content/>
element nor the <Text>
.
BUT - when I remove the <Content/>
element (leaving just the <Text/>
), test passes and I see the <Text/>
element.
If the answer is something like “NativeBase is mocking the <Content/>
in tests” - could you please elaborate further?
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Content Component in Native Base React is not rendering
I desigining react native UI using Native base library(http://docs.nativebase.io/Components.html#anatomy-headref). I am following their most ...
Read more >Components
This is a NativeBase component which renders as body element of your screen. Each screen can have only one Content component and can...
Read more >native-base
native -base. TypeScript icon, indicating that this package has built-in type declarations · Readme · Code Beta · 34 Dependencies · 288 Dependents ......
Read more >Components · Native Base Docs - Remicck
NativeBase component that renders as footer, include your favourite apps for your ... Content, Badge, Text, Icon } from 'native-base'; export default class...
Read more >How to use the native-base.Picker.Item function in ...
Platform, } from 'react-native'; import { Container, Button, Icon, Text, Header, Title, Content, Left, Body, Right, Form, Label, Input, Picker, Switch, Item as ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey! I looked into the example and it indeed doesn’t work. So I jumped into
native-base
internals and found this: https://github.com/GeekyAnts/NativeBase/blob/65f0bc7ff53b28099d177813d2b33ffd987cadcd/src/basic/Content.js#L90-L95The
Content
component usesreact-native-keyboard-aware-scroll-view
under the hood, which is just not mocked properly. I can see it’s even namedKeyboardAwareScrollViewMock
, not sure where it comes from (maybejest-expo
? I’ll leave that to you to investigate).Here’s the diff that fixes your tests (of course this mock is very basic, feel free to make it closer to the original and send a PR to the library maintainers, or use a better one if available already):
Closing, as that’s not an issue with this library, but with mocking in general.
@thymikee , thank you for the reply and I apologize for the misunderstanding.
I created the following repository to reproduce the behavior: https://github.com/pedrohbtp/rntl-content-bug