Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate string-refs to functional ones: this.refs.dotMenu #15845

Closed
Willyfrog opened this issue Oct 7, 2020 · 2 comments · Fixed by mattermost/mattermost-webapp#6957
Closed

Comments

@Willyfrog
Copy link
Contributor

Context:

String references are deprecated in React, and they will eventually disappear. Since React 16.3 there is the new api to use for reference creation createRef which improved the way to handle them greatly. Callbacks refs still have some valid usage, so we might make exceptions with those, please raise the issue if you feel you need to use them.

How to migrate

Go to ./components/rhsroot_post/rhs_rootpost.jsx and look for usage of this.refs.dotMenu. Once you find them:

  1. Remove usage this.refs.some-reference
  2. Add a this.some-reference = React.createRef()
  3. Change code depending on this.refs.some-reference into using this.some-reference.current. Be aware that this might be accessed by files other than the one that defined it. Also, you might need to refactor the code to keep behaviour the same.
  4. If there are e2e tests using that functionality run them to ensure it works as expected. Optionally consider adding any new tests that might ensure it functions as expected.
  5. Look for any other this.refs used in the file and repeat from the begining.

Example of migrated code

Questions

you can ask for help messaging @guillermo.vaya or posting in the ~webapp channel in the community server


If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.

New contributors please see our Developer's Guide.

JIRA ticket: https://mattermost.atlassian.net/browse/MM-29406

@katyasichov
Copy link

Hey, I would like to take this issue. Please assign me

@Willyfrog
Copy link
Contributor Author

hello @EGrinberg let me know if you need any help with the ticket :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants