-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Upgrade React & React-DOM & React-Router + adding DevTools #2990
Conversation
@AWolf81 Submit this issue to here. https://issuehunt.io/r/BoostIo/Boostnote/issues/2993 I'm going to pay for this pr gladly. |
browser/lib/newNote.js
Outdated
@@ -1,7 +1,9 @@ | |||
import { hashHistory } from 'react-router' | |||
// import { hashHistory } from 'react-router' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discard comments
@@ -9,7 +9,8 @@ import StarButton from './StarButton' | |||
import TagSelect from './TagSelect' | |||
import FolderSelect from './FolderSelect' | |||
import dataApi from 'browser/main/lib/dataApi' | |||
import { hashHistory } from 'react-router' | |||
// import { hashHistory } from 'react-router' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discard comments
@@ -8,7 +8,8 @@ import StarButton from './StarButton' | |||
import TagSelect from './TagSelect' | |||
import FolderSelect from './FolderSelect' | |||
import dataApi from 'browser/main/lib/dataApi' | |||
import {hashHistory} from 'react-router' | |||
// import {hashHistory} from 'react-router' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discard comments
browser/main/Main.js
Outdated
@@ -12,8 +12,8 @@ import _ from 'lodash' | |||
import ConfigManager from 'browser/main/lib/ConfigManager' | |||
import mobileAnalytics from 'browser/main/lib/AwsMobileAnalyticsConfig' | |||
import eventEmitter from 'browser/main/lib/eventEmitter' | |||
import { hashHistory } from 'react-router' | |||
import store from 'browser/main/store' | |||
// import { hashHistory } from 'react-router' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discard comments
@@ -132,8 +132,8 @@ | |||
</script> | |||
|
|||
<script src="../node_modules/@rokt33r/js-sequence-diagrams/dist/sequence-diagram-min.js"></script> | |||
<script src="../node_modules/react/dist/react.min.js"></script> | |||
<script src="../node_modules/react-dom/dist/react-dom.min.js"></script> | |||
<script src="../node_modules/react/umd/react.development.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we need to use another html file for production env because I don't want to use development script in the compiled app.
So what I want to ask are:
- Rename this file to
lib/main.development.html
- Create
lib/main.production.html
by copying fromlib/main.development.html
and update the url so we can use production script. - Update declaration statements for
const url
inlib/main-window.js
so electron can choose the html files by environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I've added this.
I've also updated the link regex or was that not needed?
What do you think should we create an issue to bundle the electron scripts and we don't have to manually import each script? Minifiying could be done by Webpack production build too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also updated the link regex or was that not needed?
I cannot understand. Could you point where the regex is in?
What do you think should we create an issue to bundle the electron scripts and we don't have to manually import each script? Minifiying could be done by Webpack production build too.
I absolutely want to do. But let's do things one by one. It should be done in another pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I think there is already issue #1561 for this. I can add some ideas I have as a comment to that issue.
First part of the todolist in that issue Upgrade React
is done once this is merged.
@Rokt33r thanks for the reward at IssueHunt. I've addressed you review comments. That created a conflict with master. Can you please fix that during merging to master? I think I can not fix that. Just the inline comment that I have added is open - should I modify this as I proposed? But it would be probably also OK to use the imported history as we're also having another location where we're doing it like this. |
@@ -1023,7 +1023,8 @@ export default class MarkdownPreview extends React.Component { | |||
|
|||
if (!href) return | |||
|
|||
const regexNoteInternalLink = /main.html#(.+)/ | |||
const regexNoteInternalLink = process.env.NODE_ENV === 'production' ? /main.production.html#(.+)/ : /main.development.html#(.+)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the regex I've metioned.
After having a second look on this I think it's important to update. I tested the regex here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. /main.[A-Za-z0-9]+.html#/ might be better to have rather than two regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea. Maybe also /main[.\w]*.html#/
will work - also supports main.html
. I'll update this later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AWolf81 Yeah I think your idea is better. Could you fix it too? Then I think we could merge this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because there is no main.development.html
in the linkHash
or href
string. Maybe new router changed here.
I have to check how to detect the local link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I have the link in markdown not right. Do I need one slash in the url? I tested with [test link](#Test)
. I was a bit in a hurry before going to work. I'll check it later today after work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try it too later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've fixed it by modifying parsing of the href string. Inspired by the following post.
Tested all link types (empty link, line link :line:<number>
, tag link #title
& note link :note:noteKey
). I just couldn't verify old link style storage.key-note.key
- not sure how to test it. But it should still work.
Note: Adding a slash to a tag link e.g. /#title
won't work but I think that's OK - same behavior as on master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ctrl+left mouse
handling in the editor is not working for every link type, right? Tested on master. I think it's using just the open external Url link - it would be good to share the link handling code for this location so the same functionality is available there.
Should we create an issue for this so it can be improved later?
@Rokt33r I've replaced the direct usage of I think it would be good to add that we recommend to use In the style guide I've seen that it's recommended to use class property over class methods. What do you think should we clean our code base to be consitent with this? During my last reviews I commented to have I think we should also add some info to React hooks and how we'd like to use them. Existing code will be kept class-based and will be only changed if it improves readability or makes things more reusable. For new components it's OK to use hooks & functional components but don't mix hooks & class-based within one feature - just for code style / readability reasons. |
Both of idea sounds great. But let's do it in other prs. And, I'm going to merge this soon. |
if (regexNoteInternalLink.test(linkHash)) { | ||
const targetId = mdurl.encode(linkHash.match(regexNoteInternalLink)[1]) | ||
const targetElement = this.refs.root.contentWindow.document.getElementById( | ||
const regexNoteInternalLink = /.*[main.\w]*.html#/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Added .*
to the regex in front of [main.\w]
to match everything before main.development.html
. The string to test contains file protocol + path e.g. file:///c:/path/to/project/main.development.html
|
||
if (regexNoteInternalLink.test(href)) { | ||
const targetId = mdurl.encode(linkHash) | ||
const targetElement = this.refs.root.contentWindow.document.querySelector( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to querySelector because targetId
contains #
e.g. #test
"react-router-redux": "^4.0.4", | ||
"react-test-renderer": "^15.6.2", | ||
"react-test-renderer": "^16.8.6", | ||
"redux-devtools": "^3.5.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue with redux-devtools
. I'm not sure if we need to fix this before merging but I'm getting the error message from the screenshot pretty often especially if I'm selecting a dom element.
During install of redux-devtools
I'm getting the following warning " > [email protected]" has incorrect peer dependency "react-redux@^4.0.0 || ^5.0.0 || ^6.0.0".
There is an issue to it here but with-out a comment. Maybe we have to change version to React-redux
6.x until this is fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can not reproduce the behaviour with the warning message at the moment. Is this still a problem? If not I think we can stay ar react-redux 7.x and ignore the warning from redux-devtools
.
@Rokt33r I've merged master into this branch & checked the issue with devtools but couldn't reproduce it. If it occurs later I think changing React-redux to 6.x version could improve/fix the problem. But we should avoid using the old version as they're working on hooks support improvements. So I think this is ready for merging or is anything open that I should check? |
You don't need to. I'm going to merge this after I merge #2983 Seems lots of people don't like this feature so I'm going to merge tomorrow and deploy again. |
@AWolf81 Could you fix the conflicts? I'm going to merge this as soon as they are fixed. |
@Rokt33r Sure, I've merged master, did a quick test and everything is working. |
Great app. I really like the app and this is my first contribution to the code base. I think this is ready for a first review but I'll do a review tomorrow (e.g. to remove development console.logs if I've missed any etc.)
Description
I've updated React, React-DOM & React-Router to the latest version. There was no issue for this open but I think it's good to update & React-carousel complaint during installation that React was not matching the library version.
I've first thought this is easier todo but it was quite some work. The main problem was React-Router as the newest version v5 is totally different compared to v2 - biggest issue was the removed query prop from history. There is a good post about how to migrate & what's different compared to v2/v3
First I wanted to migrate to v3 but this was also not working out-of the box - so I decided to migrate the routing to the latest version.
So please have a close look at every route. I think I've tested everything but maybe I have missed an edge case.
Overview
Issues in the code
isRequired
or by not rendering if an important part is missing.Possible improvements (later, no need to do it in this PR)
Issue fixed
Type of changes
Checklist:
yarn jest
passed butyarn test
failed (see screenshot below) - need to check why it failsFailed
yarn test
DevTools
Todos