Im new in ReactJS, so often get problems...
so:
@CommentBox = React.createClass
getInitialState: ->
data: []
componentWillMount: ->
request_data = null
val = $.ajax
url: @props.url
dataType: 'json'
success: (data, status, xhr) ->
request_data = JSON.parse xhr.responseText
@setState data: request_data
render: ->
.......
and get error in console:
TypeError: this.setState is not a function
return this.setState({..
semple of my repo: https://github.com/olegsobchuk/example_app
Please help me!
你可能想使用=>
代替->
为成功回调,使this
指的是您的组件:
success: (data, status, xhr) =>
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.