Skip to content

Commit

Permalink
fix: animated react native svg web (#2053)
Browse files Browse the repository at this point in the history
## Description

Add the ability to animate svg components with `createAnimatedComponent` on the web.
Cf : #1951

## Checklist

- [X] Ensured that CI passes
  • Loading branch information
Daavidaviid committed Jun 17, 2021
1 parent 00bafc2 commit 09fb12f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/reanimated2/js-reanimated/index.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ export const _updatePropsJS = (_viewTag, _viewName, updates, viewRef) => {
[{}, {}]
);

viewRef.current._component.setNativeProps({ style: rawStyles });
if (typeof viewRef.current._component.setNativeProps === 'function') {
viewRef.current._component.setNativeProps({ style: rawStyles });
} else if (Object.keys(viewRef.current._component.props).length > 0) {
Object.keys(viewRef.current._component.props).forEach((key) => {
if (!rawStyles[key]) {
return;
}
const dashedKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
viewRef.current._component._touchableNode.setAttribute(
dashedKey,
rawStyles[key]
);
});
} else {
console.warn('It is not possible to manipulate component');
}
}
};

Expand Down

0 comments on commit 09fb12f

Please sign in to comment.