Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
DefaultLayout,
} from './reanimated2/layoutReanimation/defaultAnimations/Default';
import { isJest, isChromeDebugger } from './reanimated2/PlatformChecker';
import { initialUpdaterRun } from './reanimated2/animation';

const NODE_MAPPING = new Map();

Expand Down Expand Up @@ -77,6 +78,7 @@ export default function createAnimatedComponent(Component, options = {}) {
_invokeAnimatedPropsCallbackOnMount = false;
_styles = null;
_viewTag = -1;
_isFirstRender = true;

constructor(props) {
super(props);
Expand Down Expand Up @@ -456,7 +458,14 @@ export default function createAnimatedComponent(Component, options = {}) {
if (style && style.viewDescriptors) {
// this is how we recognize styles returned by useAnimatedStyle
style.viewsRef.add(this);
return style.initial.value;
if (this._isFirstRender) {
return {
...style.initial.value,
...initialUpdaterRun(style.initial.updater),
};
} else {
return style.initial.value;
}
} else {
return style;
}
Expand Down Expand Up @@ -507,6 +516,10 @@ export default function createAnimatedComponent(Component, options = {}) {
props.animatedStyle = this.animatedStyle;
}

if (this._isFirstRender) {
this._isFirstRender = false;
}

const platformProps = Platform.select({
web: {},
default: { collapsable: false },
Expand Down
3 changes: 2 additions & 1 deletion src/reanimated2/hook/useAnimatedStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface AnimatedState {
interface AnimationRef {
initial: {
value: AnimatedStyle;
updater: () => AnimatedStyle;
};
remoteState: AnimatedState;
sharableViewDescriptors: SharedValue<Descriptor[]>;
Expand Down Expand Up @@ -428,6 +429,7 @@ export function useAnimatedStyle<T extends AnimatedStyle>(
initRef.current = {
initial: {
value: initialStyle,
updater: updater,
},
remoteState: makeRemote({ last: initialStyle }),
sharableViewDescriptors: makeMutable([]),
Expand All @@ -443,7 +445,6 @@ export function useAnimatedStyle<T extends AnimatedStyle>(
const { initial, remoteState, sharableViewDescriptors } = initRef.current!;
const maybeViewRef = NativeReanimated.native ? undefined : viewsRef;

initial.value = initialUpdaterRun(updater);
useEffect(() => {
let fun;
let upadterFn = updater;
Expand Down