Reputation: 11404
In React-Native 0.62.2, the proper syntax for setting resizeMode seems to be:
<Image style={{width: 20, height: 20}} resizeMode="contain" />
However, I accidentally did the following:
<Image style={{width: 20, height: 20, resizeMode: 'contain'}} />
and it also sets the resizeMode to contain the image.
Why are both of these methods working? Are both methods equally valid? Can the same be done with other JSX properties?
Upvotes: 1
Views: 54
Reputation: 10719
Both ways are possible. If you have a look into the code (line 112), you'll see the following:
const resizeMode = props.resizeMode || style.resizeMode || 'cover';
Can the same be done with other JSX properties?
No, this is clearly an exception. There was a lot of confusion going on, that's why the developers made both things possible.
Upvotes: 1