Skip to content

鸿蒙 hippy-react 3.0 Text动态内容宽度不会自适应 #4471

@dengp

Description

@dengp

期望结果

文字动态变化时宽度可以自适应 不需要加key进行重新渲染

实际结果

同一个Text标签 文字从短变长 宽度不会撑开 会换行 加了key才可以

重现链接

No response

重现步骤

No response

重现环境

No response

补充说明

import React, {useEffect, useState} from 'react'
import { StyleSheet, View, Text } from '@hippy/react'

const styles = StyleSheet.create({
  btn: {
    flexDirection: 'row',
    height: 44,
    backgroundColor: 'rgba(255, 93, 31, 0.9)',
    borderRadius: 44,
    justifyContent: 'center',
    alignItems: 'center'
  }
})

const TestText = () => {
  const [str, setStr] = useState('你好')
  useEffect(() => {
    setTimeout(() => {
      setStr('你好你好你好你好你好你好')
    }, 3000)
  }, [])
  return (
    <View style={styles.btn}>
      <Text>{str}</Text>
    </View>
  )
}
export default TestText

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions