Closed stevensonmt closed 7 years ago
Hi @stevensonmt thanks for the issue. Please clarify in this code as I am not sure what you are suggesting...
class Message < React::Component::Base
param :message, type: Hash
after_mount :scroll_to_bottom
after_update :scroll_to_bottom
def render
div.row.alternating.message do
div.col_sm_2 { params.message[:from] }
FormattedDiv class: "col-sm-8", markdown: params.message[:message]
div.col_sm_2 { Time.at(params.message[:time]).to_s }
end
end
def scroll_to_bottom
Element['html, body'].animate({scrollTop: Element[Document].height}, :slow)
end
end
The code on github is correct and works, but in the tutorial it says to put the function in Messages component while putting the function call in the Message(no -s) component. This results in a no method error. So it is the tutorial, not the code that needs to be corrected. See the screenshot below.
@stevensonmt - thanks so much. I know some folks like to help with PRs, if you want to fix this and submit a PR that's great, otherwise we will get this updated. Just want to give you the chance to contribute if you are interested.
@stevensonmt funny that both your issues pertain to an additional S!
As @catmando said, you are most welcome to issue an PR and I will merge it, or if you prefer I am happy to make the change myself.
If you do want to do a PR then please issue it against this branch: https://github.com/ruby-hyperloop/ruby-hyperloop.io/tree/source
Opened pull request. Bit of a newb, so please let me know if I screwed that up.
@stevensonmt that was perfect. I have deployed the change.
The tutorial says the
scroll_to_bottom
method should be in the Messages component but then called in the Message component.If you do that there's a
no method
error and it does not scroll automatically. Putting the method in the Message component OR putting the call to the method in the Messages component solves the issue. The latter seems to be what is done in the source index.html on github.