Hi,
i get this error, You attempted to set the key ‘social’ with the value “twitter” on an object that is meant to be immutable and has been frozen.
Filtering out the most rated answers from issues on Github |||||||||||_______|||| Also a sharing corner
Hi,
i get this error, You attempted to set the key ‘social’ with the value “twitter” on an object that is meant to be immutable and has been frozen.
Comments are closed.
Hi,
i get this error, You attempted to set the key ‘social’ with the value “twitter” on an object that is meant to be immutable and has been frozen.
i solve the problem. it’s error when assign object. It can’t set key ‘social’ when you share a second time.
i fixed it like this:
import React, { Component } from 'react'
import {
Clipboard,
ToastAndroid,
AlertIOS,
Platform
} from 'react-native'
import Share, { ShareSheet, Button } from 'react-native-share'
export default class TestShare extends Component {
constructor (props) {
super(props)
this.state = {
visible: false
}
}
componentWillMount () {
this.setState({ shareOptions: this.props.shareOptions })
}
onCancel () {
console.log('CANCEL')
this.setState({ visible: false })
}
onOpen () {
console.log('OPEN')
this.setState({ visible: true })
}
render () {
return (
<ShareSheet visible={this.state.visible} onCancel={this.onCancel.bind(this)}>
<Button iconSrc={{ uri: TWITTER_ICON }}
onPress={() => {
this.onCancel()
setTimeout(() => {
Share.shareSingle({
title:this.state.shareOptions.title,
message: this.state.shareOptions.message,
url: this.state.shareOptions.url,
subject: this.state.shareOptions.subject,
social: 'twitter'
})
}, 300)
}}>Twitter</Button>
<Button iconSrc={{ uri: FACEBOOK_ICON }}
onPress={() => {
this.onCancel()
setTimeout(() => {
Share.shareSingle({
title:this.state.shareOptions.title,
message: this.state.shareOptions.message,
url: this.state.shareOptions.url,
subject: this.state.shareOptions.subject,
social: 'facebook'
})
}, 300)
}}>Facebook</Button>
<Button iconSrc={{ uri: WHATSAPP_ICON }}
onPress={() => {
this.onCancel()
setTimeout(() => {
Share.shareSingle({
title:this.state.shareOptions.title,
message: this.state.shareOptions.message,
url: this.state.shareOptions.url,
subject: this.state.shareOptions.subject,
social: 'whatsapp'
})
}, 300)
}}>Whatsapp</Button>
<Button iconSrc={{ uri: GOOGLE_PLUS_ICON }}
onPress={() => {
this.onCancel()
setTimeout(() => {
Share.shareSingle({
title:this.state.shareOptions.title,
message: this.state.shareOptions.message,
url: this.state.shareOptions.url,
subject: this.state.shareOptions.subject,
social: 'googleplus'
})
}, 300)
}}>Google +</Button>
<Button iconSrc={{ uri: EMAIL_ICON }}
onPress={() => {
this.onCancel()
setTimeout(() => {
Share.shareSingle({
title:this.state.shareOptions.title,
message: this.state.shareOptions.message,
url: this.state.shareOptions.url,
subject: this.state.shareOptions.subject,
social: 'email'
})
}, 300)
}}>Email</Button>
<Button
iconSrc={{ uri: CLIPBOARD_ICON }}
onPress={() => {
this.onCancel()
setTimeout(() => {
if (typeof this.props.shareOptions['url'] !== 'undefined') {
Clipboard.setString(this.props.shareOptions['url'])
if (Platform.OS === 'android') {
ToastAndroid.show('Link copiado al portapapeles', ToastAndroid.SHORT)
} else if (Platform.OS === 'ios') {
AlertIOS.alert('Link copiado al portapapeles')
}
}
}, 300)
}}>Copy Link</Button>
</ShareSheet>
)
}
}
Change
Share.shareSingle(Object.assign(this.shareOptions, {“social”: type})).catch(err => console.log(err))
to
Share.shareSingle(Object.assign({},shareOptions, {
“social”: “email”
})).catch(err => console.log(err));
Props are already frozen in development mode, assign properties of several objects on to a new target object, so we don’t mutate any exist data.
Comments are closed.
Copyright © 2022 Fantas...hit
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
i solve the problem. it’s error when assign object. It can’t set key ‘social’ when you share a second time.
i fixed it like this:
Change
Share.shareSingle(Object.assign(this.shareOptions, {“social”: type})).catch(err => console.log(err))
to
Share.shareSingle(Object.assign({},shareOptions, {
“social”: “email”
})).catch(err => console.log(err));
Props are already frozen in development mode, assign properties of several objects on to a new target object, so we don’t mutate any exist data.