Skip to content

Using default value for function parameter. #141

Closed Answered by jpudysz
DiegoGielda asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, you need to follow React rules. You can't run useStyles outside of the React component.

In order to fix it, you need to do something like this:

const ProgressBar = (
  {
     title,
     startValue,
     endValue = 100,
     current, 
     goal,
     lack,
     colorBar
  }: ProgressBarProps) => {
  const { styles, theme } = useStyles(stylesSheet);
  
const { styles } = useStyles(stylesSheet);
  const animated = useSharedValue(0);
  const [width, setWidth] = useState(0);

  const progressBarAnimated = useAnimatedStyle(() => {
    return {
      transform: [{
        translateX: animated.value
      }],
      backgroundColor: colorBar ?? theme.colors.progressBar.default,
    }
  });

}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DiegoGielda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants