Skip to content
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

Error in measure: Missing required text #20

Open
kirtishjain9 opened this issue Sep 12, 2019 · 1 comment
Open

Error in measure: Missing required text #20

kirtishjain9 opened this issue Sep 12, 2019 · 1 comment

Comments

@kirtishjain9
Copy link

kirtishjain9 commented Sep 12, 2019

Hi,

I'm getting following error when try this library to calculate height of text in iOS:

'Error in measure:', { [Error: Missing required text.] framesToPop: 1, code: 'E_MISSING_TEXT', domain: 'RCTErrorDomain', userInfo: null}

My code snippet: for JS - HeightMeasurementFromText.js

import React, { Component } from 'react'; import { Platform } from 'react-native';

import RNTextSize, { TSFontSpecs } from 'react-native-text-size';

const fontSpecs: TSFontSpecs = { fontFamily: (Platform.OS === 'ios' ? 'Proxima Nova' : 'Proxima Nova Bold'), fontWeight: (Platform.OS === 'ios' ? 'bold' : null), fontSize: 18, }

export const nameTextHeight = async (nameText) => { const dimension = { width: 0, height: 0, };
await RNTextSize.measure({ nameText, width: 170, ...fontSpecs, }).then(result => { console.log('result - ' + JSON.stringify(result)); dimension.width = result.width; dimension.height = result.height; }).catch((err) => { console.log('Error in measure:', err); });
return dimension; };

I'm calling this in my some other JS file as:

import { nameTextHeight } from './library/helper/HeightMeasurementFromText';

let nameTextHgt = nameTextHeight(item.name.toUpperCase());

My Environment variables are:

"react": "16.8.3",
"react-native": "^0.59.9",
"react-native-text-size": "^4.0.0-rc.1",

What's the problem in my code and implementation of your library?

Kindly suggest. Please.

Thanks in advance.

@savaughn
Copy link

savaughn commented May 3, 2023

The text property is incorrectly named. You changed the text field to nameText.
await RNTextSize.measure({ nameText, width: 170, ...fontSpecs, })

Update to await RNTextSize.measure({ text: nameText, width: 170, ...fontSpecs, })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants