最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Fontweight - Bold not working in react native page - Stack Overflow

programmeradmin5浏览0评论

I am new to React Native, now I want to make a sample project. I see there is an option for making a text bold by using 'fontWeight'.

I am Using expo.

But even if I use this property for my <Text> tag, I can't see any changes.

Can you suggest me any possibilities and solutions?

Here is what i tried.

import React, { Component } from 'react';
import { StyleSheet, Text, View, Button, TouchableOpacity } from 'react-native';
import { Image } from 'react-native';
import { FlatList, ActivityIndicator } from 'react-native';

export default class Screen1 extends Component {
  //Screen1 Component
  constructor(props){
    super(props);
  }

  render() {

      return(
        <View style={{flex: 1, padding: 20}}>
          <Text style={{ fontWeight: 'bold' }} >Bold Text</Text>
        </View>
      )
    }

}

I am new to React Native, now I want to make a sample project. I see there is an option for making a text bold by using 'fontWeight'.

I am Using expo.

But even if I use this property for my <Text> tag, I can't see any changes.

Can you suggest me any possibilities and solutions?

Here is what i tried.

import React, { Component } from 'react';
import { StyleSheet, Text, View, Button, TouchableOpacity } from 'react-native';
import { Image } from 'react-native';
import { FlatList, ActivityIndicator } from 'react-native';

export default class Screen1 extends Component {
  //Screen1 Component
  constructor(props){
    super(props);
  }

  render() {

      return(
        <View style={{flex: 1, padding: 20}}>
          <Text style={{ fontWeight: 'bold' }} >Bold Text</Text>
        </View>
      )
    }

}

Share Improve this question edited Aug 2, 2019 at 4:42 asked Aug 1, 2019 at 19:36 user11533977user11533977
Add a ment  | 

3 Answers 3

Reset to default 1

your mistake in TEXT tag , try this

  <Text style={{ fontWeight: 'bold' }} >Bold Text</Text>

There isn't an issue with your style, your style is perfect as it is { fontWeight: 'bold' }, but your <Text/> ponent is not correctly.

<Text/>Bold Text</Text>

You have an extra '/' inside of your JSX ponent. It should be like this:

<Text>Bold Text</Text>

Want to see an example? https://snack.expo.io/@abranhe/bold-example

import React from 'react';
import { View, Text } from 'react-native';

export default () => (
  <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
    <Text style={{ fontWeight: 'bold' }}>Bold Text</Text>
  </View>
);

By the way, you are also missing React from your imports, and it is required.

the issue was solved by changing my mobile's system font. I have changed my system font once. that was not accepting Bold. that was the issue.

发布评论

评论列表(0)

  1. 暂无评论