Error: The text in the NativeBase Button is not displaying

I'm facing an issue where the buttons in NativeBase are not displaying their text. I followed the sample code from their website documentation, but when I run the code, the buttons appear without any titles. Any suggestions on how to fix this? Here's the code snippet:

App.js

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import MenuButton from './MenuButton';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.textStyle}>Welcome to the App</Text>
        <MenuButton/>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    top: 40,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  textStyle:{
   fontSize: 30
  }
});

MenuButton.js:

import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Container, Content, Button, Badge } from 'native-base';
export default class MenuButtons extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <Button style={styles.button} textStyle={styles.buttonText}> HeLLO!! </Button>
                    <Button style={styles.button} bordered large> Info </Button>
                    <Button style={styles.button} bordered capitalize={true}> Primary </Button>
                </Content>
            </Container>
        );
    }
}

const styles = StyleSheet.create({
    button: {
        backgroundColor: 'orange',
        paddingBottom: 30,
        paddingTop: 30,
        width: 350,
        height:40,
    },
    buttonText:{
        fontSize:40,
        color:'black'
    }
});

Answer №1

After removing the "paddingTop" and "paddingBottom" properties, the text suddenly appeared on the screen.

Answer №2

To properly format the text within Button tags, make sure to enclose it with <Text> tags. You can check out this example for reference: (Updated - Padding styles have been removed from the button)

<Button style={styles.button}><Text style={styles.buttonText}>HeLLO!!</Text></Button>
<Button style={styles.button} bordered large><Text>Info</Text></Button>
<Button style={styles.button} bordered><Text>Primary</Text></Button>

Answer №3

Observing the provided code excerpt, it appears that the recommended documentation is not being adhered to.

The component Text should be imported from the package native-base, rather than from react-native.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The file upload issue with FormData append in CodeIgniter is causing errors

My current challenge involves uploading files using AJAX to my CodeIgniter based website. Unfortunately, I am encountering an issue where I cannot retrieve the file field value in the controller. This results in an error message stating "Undefined index: & ...

Maximizing the potential of a cell in a table

I am currently using AJAX to retrieve and display data in my table. However, I want to capture the actual value from the selected cell in the table. To better display user needs, I have split the returned value to obtain specific items. Below is the scri ...

Utilizing document.getElementById().value in hidden fields for asp.net web pages does not function correctly

Recently, I developed a basic website using ASP.NET Web Pages with Razor markup. The site includes a form with two hidden fields: latitude and longitude. My goal was to utilize the HTML5 Geolocation API in my JavaScript script to obtain the user's loc ...

The `tailwind.min.css` file takes precedence over `tailwind.css` in my Nuxt

Having trouble configuring Tailwind to use a custom font without it overriding the tailwind.css file and not displaying the changes? https://i.stack.imgur.com/ExDCL.png Check out my files below. // tailwind.config.js const defaultTheme = require('ta ...

How can the client be informed about the ongoing processing of the request by the servlet?

In my web application, I have JS/jQuery on the front end and servlets on the back end. When making a request to a servlet, it performs multiple tasks in one call (such as executing a shell script that runs various Python scripts). My main query is whether ...

Unable to transfer Base64 encoded data to C# through AJAX

I'm facing an issue where a base64 string I send through ajax to an aspx page with C# code behind always arrives empty. Despite other form fields posting successfully, this particular string is not making it through. The base64 string in question app ...

Comparing the distinction between assigning values to res and res.locals in a Node.js application using Express

Greetings! I am inquiring about the utilization of res (Express response object) and res.locals in Express. During my exploration of nodejs, I came across a code snippet that consists of a middleware (messages.js), a server (app.js), and a template (messa ...

Ant Design is incompatible with React JS projects and cannot be effectively utilized

import React from 'react'; import styled from "styled-components"; import {Col, Row} from "antd"; const TitleBig = styled.div` font-family: "Bebas Neue Pro"; font-size: 20px; `; const TitleSmall = styled.div` ...

Error: TypeScript encountered an issue while attempting to access a property that is undefined

I just can't seem to figure out what's missing here. Running the following code gives me this error: Uncaught TypeError: Cannot read property 'addEventListener' of undefined" class Editor{ public co ...

Ways to effectively incorporate Bootstrap into Lit?

Currently, I am in the process of converting a website from Polymer to Lit. I have made good progress with it, but I have encountered a roadblock when it comes to styling. In order to simplify development and focus on functionality, I have been following t ...

Attempting to achieve dynamic text changes in the Bootstrap dropdown button based on the selected item

I am currently using Bootstrap to style a dropdown button, and I want the button text to change based on the item selected from the dropdown. I believe that using JavaScript is the most effective way to achieve this, but I am not very familiar with it ye ...

How to extract IDs from a URL in Angular

I'm facing an issue with retrieving the first id from an image URL. Instead of getting the desired id, I am receiving the one after the semicolon ("id" = 1). I have tried various methods but haven't been successful in resolving this issue. Any su ...

Trouble with Syntax in Angular App While Declaring a Variable

Managing pagination in my Angular application has been a smooth process with the function I have implemented. It involves subscribing to URL parameters and then using the router to navigate based on those parameters, including the page number passed as a v ...

Guide on accessing and setting values in GridView Cell using JavaScript

Within my layout, I have two labels named FixedTotal and TotalPercent, as well as a single row GridView with columns labeled ReferenceID, Percentage, and Amount. ReferenceID Percentage Amount -------------- ------------- --- ...

When my webpage is opened in Firefox, I notice that it automatically scrolls down upon loading

I recently embarked on the task of building a website from scratch but ran into an unusual bug in Firefox. The issue causes the page to scroll down to the first div, completely bypassing its margin. I want to clarify that I am not seeking a solution spe ...

Incorporating an array attribute into a current array of elements

I am currently attempting to incorporate the days of the week into an existing array of objects. To give you a visual representation, check out this image: https://i.stack.imgur.com/0jCBF.png After filtering my array to only yield 7 results, I aim to assi ...

Display a division upon clicking a hyperlink with a specific class

My goal is to display/fade in a <div> with an ID of "signInHold" when the <li> "Sign In" is clicked, utilizing the class signInActive on the <li>. <ul class="nav1"> <li class="nav2"> <a href="http://rocketcss.c ...

What methods are available for me to apply a filter on an API?

I am working with the MovieDB API and want to implement a search bar for filtering. I could really use some assistance as I'm not sure how to get started. The requirement is to utilize JavaScript/jQuery for the code and only filter based on keywords. ...

Ensure that test cases in Angular2 include a line that covers conditions for returning values

I'm having trouble implementing test coverage for an online platform, as I'm not sure how to approach it. Within my service method, I have the following code: public getResults() { return this.http(url,body).map(this.mapResponse); } private ...

Issue with Collapse Feature on Bootstrap 3.x Navbar

The Bootstrap 3 Navbar expands properly in full screen and on a browser with a small width on a desktop PC and mobile browsers, but when using the Toggle navigation button, it doesn't slide down. I have tried to replicate the code from this example: h ...