<Calendar
markedDates={{`${this.state.currentDate}%`: {selected: true, marked: false, selectedColor: '#ff7f00'},}}
onDayPress={(day) => this.manageGroups(day)}
/>
I am trying to set the marked date on the calender to the currentDate state. however, doing it this way is yielding in a syntax error. How can I solve this? I have provided the link to the source of where I got my calender from.
Setting state in ReactJS can be done in 2 ways:
this.setState()
function, used in stateful components (which means components built with class ComponentName extends React.Component
), you can read more in the React docs here . useState
hook in stateless components (which means components which are pure functions, built with const ComponentName = () => {}
, you can read more about the state hook in the React docs here . What you added in your code snippet is a way to read the state. However you have a %
symbol at the end of the state declaration, which is unnecessary and that's probably what's causing your syntax error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.