0
    const Styles = () => {
  containerStyle: {
    borderWidth: 1,
    borderRadius:2,
    borderColor: '#ddd',
    borderBottomWidth: 0,
    shadowColor: '#000',
    shadowOffset: {width: 0, height: 2},
    shadowOpacity: 0.1,
    shadowRadius: 2,
    elevation:1,
    marginLeft: 5,
    marginRight: 5,
    marginTop: 10

  }

I am trying to do this styling in react.js. But the console shows parse error in for borderRadius:2, Error is as: Unexpected token , expected ;

2
  • Put attention in the brackets Commented Jan 11, 2017 at 0:02
  • Try to replace the border radius values, use strings instead, and tell us what's going on. Commented Jan 11, 2017 at 0:05

2 Answers 2

1

In your example, you are missing closing bracket for Styles object.

const Styles = () => ({
    containerStyle: {
        borderWidth: 1,
        borderRadius:2,
        borderColor: '#ddd',
        borderBottomWidth: 0,
        shadowColor: '#000',
        shadowOffset: {width: 0, height: 2},
        shadowOpacity: 0.1,
        shadowRadius: 2,
        elevation:1,
        marginLeft: 5,
        marginRight: 5,
        marginTop: 10,
    },
});
Sign up to request clarification or add additional context in comments.

2 Comments

Excuse me but I must have missed it here. But problem is not the bracket it is as stated in the question.
See updated answer. It's about brackets. When returning object literal, you have to wrap it in ()
0

It turns out in my project this const Styles should have been an object instead of the function. Hence it was showing error and was asking for ; instead of ,. Thanks

1 Comment

You are wrong. It was not complaining about Styles being a function, instead of object. See my answer, you forgot to wrap returned object in ()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.