question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useSharedValue is not a function

See original GitHub issue

Description

Followed the steps to install alpha 8, then proceeded to setup my view, however none of the react-native-reanimated 2 hooks are available?

Looking at the default Animated object and I can’t see the hooks there either.

image

And looking node_modules/react-native-reanimated/src/reanimated2 has Hooks.js which has the correct hooks.

babel.config.js looks like:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ['react-native-reanimated/plugin'],
  env: {
    production: {
      plugins: ['react-native-paper/babel'],
    },
  },
}

Screenshots

Simulator Screen Shot - iPhone 11 - 2020-11-11 at 22 56 36

Steps To Reproduce

  1. Try using any of the new hooks via import

Expected behavior

Hook is available

Actual behavior

Hook isn’t found

Snack or minimal code example

import React from 'react'
import Animated, { useSharedValue } from 'react-native-reanimated'

export const Screen = ({ route, navigation }) => {
  const height = useSharedValue(0)

  return null
}

Package versions

  • React: 16.14.0
  • React Native: 0.63.3
  • React Native Reanimated: 2.0.0-alpha.8
  • NodeJS: v12.14.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mdconecommented, Nov 12, 2020

@shockdesign, the react-native bundler. To get rid of its cache fire it up with react-native start --clear-cache.

0reactions
jakub-gonetcommented, Dec 28, 2020

@canberkardic do you use npm by any chance? We saw similar reports in the past. Try using yarn and if you can, please provide a reproducible repository – that will greatly help us resolve this error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing error: useSharedValue is not a function while testing
I'm using react-native-reanimated and when I'm testing, useSharedValue throws an error that it's not a function when using jest and ...
Read more >
useSharedValue | React Native Reanimated - Software Mansion
Use this hook to create a reference to a JavaScript value that can be shared with worklets. Shared Values serve a similar purpose...
Read more >
Reanimated - Expo Documentation
Reanimated uses React Native APIs that are incompatible with "Remote JS Debugging" for JavaScriptCore. In order to use a debugger with your app...
Read more >
React Native Reanimated - Nabeel Valley
module.exports = function (api) { api.cache(true); return { presets: ... Can be created using the useSharedValue hook, similar to Animated.value but can ...
Read more >
An Introduction to React Native Reanimated 2 - Amimetic
This takes a function which defines (animated) styles. ... Text, View } from "react-native" import Animated, { useSharedValue, useAnimatedStyle, withSpring, } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found