Replies: 1 comment
|
react-spring v9+ splits into a renderer-agnostic core ( Minimal custom target structure: // 1. Create an Animated host using @react-spring/core
import { createStringInterpolator, Globals } from '@react-spring/shared';
import { createHost } from '@react-spring/core';
// Define which element props are animatable
const primitives = {
View: RemaxView, // your Remax component
Text: RemaxText,
// ... other Remax primitives
};
// createHost connects react-spring's animation engine to your components
const { animated, useSpring, useTransition, /* etc */ } = createHost(primitives, {
// Interpolator for CSS-like string values ("0px 10px" → "5px 10px")
createStringInterpolator,
// Optional: handle special prop transforms
applyAnimatedValues: (instance, props) => {
if (typeof instance.setNativeProps === 'function') {
instance.setNativeProps(props);
} else {
Object.assign(instance, props);
}
},
});
export { animated, useSpring, useTransition };Usage after creating: import { animated, useSpring } from './remax-spring';
function MyComponent() {
const style = useSpring({ opacity: 1, from: { opacity: 0 } });
return <animated.View style={style}>Hello</animated.View>;
}Reference implementation: look at The |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I want to create a target for remaxjs,how could I do that? For now I just fork
remax-springfor alternative.All reactions