question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Single TSpan misplaced after forced rerender

See original GitHub issue

Using TSpans, the position of the text does not match the expected position after rerendering. In this example, we force the “!” to be rerendered by changing its color, which unexpectedly changes its position on screen, too, while the other TSpans remain (not rerendered) remain at their original position. Interestingly, if we force every TSpan to rerender (by giving them the prop fillOpacity={this.state.fop}) the positioning is correct.

import React, { Component } from 'react';
import Svg, { TSpan, Text } from 'react-native-svg'

export default class App extends Component {
  constructor(props) {
    super();
    this.state = { fop: 1 };
    setInterval(this.tick, 500)
  }

  tick = () => {
    this.setState({ fop: 1 - this.state.fop });
  }

  render() {
    return (
      <Svg
        height="100%"
        width="100%"
      >
        <Text y={100} fontSize={100}>
          <TSpan >1</TSpan>
          <TSpan >2</TSpan>
          <TSpan stroke="black" fillOpacity={this.state.fop}>!</TSpan>
          <TSpan >3</TSpan>
        </Text>
      </Svg>
    );
  }
}

react-native info:

info 
  React Native Environment Info:
    System:
      OS: Linux 4.15 Ubuntu 16.04.5 LTS (Xenial Xerus)
      CPU: (4) x64 Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
      Memory: 1.40 GB / 7.67 GB
      Shell: 4.3.48 - /bin/bash
    Binaries:
      Node: 10.15.1 - /usr/bin/node
      npm: 6.4.1 - /usr/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      Android SDK:
        API Levels: 19, 24, 25, 26, 27, 28
        Build Tools: 27.0.3, 28.0.3
        System Images: android-28 | Intel x86 Atom_64
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.1 => 0.59.1 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-svg: 9.2.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

2reactions
msandcommented, Mar 22, 2019

@ankardon Can you try with the latest commit from the develop branch?

1reaction
ankardoncommented, Mar 23, 2019

@msand, thank you for the quick reply once again. Your fix solved the problem! The TSpans now behave as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to re-render span tags in JSX that are saved in state in ...
The problem is that the components you create during componentWillMount render only the first time the component is mounted. So, you need to ......
Read more >
Using OpenID Connect (OIDC) to Protect Service Applications ...
The Single-page application uses Authorization Code Flow to authenticate the user and retrieve tokens from the OpenID Connect provider.
Read more >
How Analysis Works for Multi-table Data Sources that Use ...
The following examples show how analysis differs between single table and multi-table data sources. This example shows three tables of movie data: ...
Read more >
Force merge API | Elasticsearch Guide [8.5] | Elastic
Use the force merge API to force a merge on the shards of one or more indices. Merging reduces the number of segments...
Read more >
A Story of a React Re-Rendering Bug - Engineering Blog
This blog will take you on a short journey about how I fixed a particularly annoying bug that existed in one of our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found