Skip to content
This repository was archived by the owner on May 13, 2019. It is now read-only.
This repository was archived by the owner on May 13, 2019. It is now read-only.

transform 首次渲染不生效 #252

@cpunion

Description

@cpunion

可重现代码如下:

class ReactNativeWebExample extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      translateX: new Animated.Value(100)
    }
  }

  render() {
    // 暂时用这方法强行生效
    if (!this._rendered) {
      setTimeout(() => {
        this.state.translateX.setValue(100)
      })
      this._rendered = true
    }

    return (
      <View style={{width: 300, height: 400, borderWidth: 1}}>
        <Animated.View style={{
          width: 200,
          height: 200,
          borderWidth: 1,
          borderColor: 'red',
          transform: [this.state]
        }}>
        </Animated.View>
      </View>
    );
  }
}

预期内部的View偏移100,render里面加了一段代码修改Animated.Value值才生效,否则style上没有添加transform。

版本:
macOS 10.12.5
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

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