Coder Social home page Coder Social logo

Comments (12)

tjzel avatar tjzel commented on June 26, 2024 2

I hate it when property is not configurable

from react-native-reanimated.

efstathiosntonas avatar efstathiosntonas commented on June 26, 2024 1

@piaskowyk can you please take a look into this? (tagging you since you fixed the similar linked issue).

It happens with runOnJS too, eg:

const [showPlayButton, setShowPlayButton] = useState(!user?.gif_autoplay);
const [currentIndex, setCurrentIndex] = useState(0);

const selectedPageHandler = useAnimatedPagerSelectedPageHandler({
    onPageSelected: (e) => {
      "worklet";
      currentPage.value = e.position;
      runOnJS(setShowPlayButton)(!user?.gif_autoplay);
      runOnJS(setCurrentIndex)(e.position);
    }
  });

This line will throw: tsx runOnJS(setShowPlayButton)(!user?.gif_autoplay); while the next line won't.

from react-native-reanimated.

tjzel avatar tjzel commented on June 26, 2024 1

I've just released an rc1 version of Reanimated (3.13.0-rc.1) that should solve this issue. Please check if it works for you.

from react-native-reanimated.

efstathiosntonas avatar efstathiosntonas commented on June 26, 2024 1

Thanks @tjzel! Been using

if (descriptor && !descriptor.configurable) {
      return;
    }

from comment above since I posted the comment and no issues so far so 3.13.0-rc.1 should be fine!

from react-native-reanimated.

github-actions avatar github-actions commented on June 26, 2024

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

from react-native-reanimated.

TomCorvus avatar TomCorvus commented on June 26, 2024

I have the same problem since 3.12.0 version.
To reproduce this error, just call a variable from StyleSheet.create to set a property value in useAnimatedStyle hook. Like this:

export const useStyles = () => {
	const styles = StyleSheet.create({
		container: {
			marginTop: 16
		} as ViewStyle,
	})
	return styles
}
export default useStyles
const animatedStyle = useAnimatedStyle(() => ({
	marginTop: styles.container.marginTop,
	opacity: interpolate(
		scrollOffsetY.value,
		[0, TOP_SCROLL_DISTANCE],
		[0, 1],
		Extrapolation.CLAMP,
	),
}))

@szydlovsky Did you see this issue before releasing 3.12.0 version?

from react-native-reanimated.

quocluongha avatar quocluongha commented on June 26, 2024

I also encounter the same problem after upgrading from 3.11.x to 3.12.0.
For me it happened when I try to call a function exposed by a component via its ref, using React.createRef.

Modal.tsx

export const ModalRef = createRef()

export const Modal = props => {
  return <ModalComponent ref={BottomTabBarRef} {...props} />
};

App.tsx

<>
  <Child />
  <Modal />
</>

Child.tsx

useAnimatedReaction(
  () => ({...}),
  ({ ... }) => {
     runOnJS(ModalRef.current.show)() // <-- Works fine before upgrading to 3.12.0
  }
);

from react-native-reanimated.

MichaelDanielTom avatar MichaelDanielTom commented on June 26, 2024

I also experienced this while trying to use StyleSheet.hairlineWidth within useAnimatedStyle. One thing to note is that it did not need to actually be called to crash, only to be somewhere in the code in the worklet. A temporary workaround for me was to define const hairlineWidth = StyleSheet.hairlineWidth; outside of the worklet, and then use that value in the worklet, so I'd assume this would work for StyleSheet.absoluteFillObject.

from react-native-reanimated.

akuul avatar akuul commented on June 26, 2024

Encountered same issue with 3.12.0.

Minimal snippet to reproduce error:

const animatedSwitchKnob = useAnimatedStyle(() => {
    const [offsetLeft, offsetRight] = [
      styles.inner.paddingStart,
      styles.inner.paddingEnd,
    ];
   <...>
  }, [activated]);
const styles = StyleSheet.create({
  inner: {
    paddingStart: 4,
    paddingEnd: 4,
  },
});

from react-native-reanimated.

efstathiosntonas avatar efstathiosntonas commented on June 26, 2024

@tjzel @kmagiera sorry for breaking balls about this issue, is someone looking into it? It's impossible to work 😓

I could downgrade to 3.11.x but why should I? haha

from react-native-reanimated.

giantslogik avatar giantslogik commented on June 26, 2024

Patch package that fixed a similar issue: #6082 (comment)

from react-native-reanimated.

efstathiosntonas avatar efstathiosntonas commented on June 26, 2024

I think we should check if the property is configurable on shareables.ts freezeObjectIfDev function:

Object.entries(value).forEach(([key, element]) => {
Object.defineProperty(value, key, {

Object.entries(value).forEach(([key, element]) => {
    const descriptor = Object.getOwnPropertyDescriptor(value, key);
    if (descriptor && !descriptor.configurable) {
      return;
    }
...

from react-native-reanimated.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.