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

React conversion #900

Closed
8 of 11 tasks
ycanardeau opened this issue Jul 3, 2021 · 0 comments
Closed
8 of 11 tasks

React conversion #900

ycanardeau opened this issue Jul 3, 2021 · 0 comments
Labels
complexity: high 7 to 30 days of work (or longer), consider splitting frontend Presentation layer (visible to user) React JavaScript library: React

Comments

@ycanardeau
Copy link
Contributor

ycanardeau commented Jul 3, 2021

Tasks

Motivation

Currently we are facing several issues with frontend development.

It's impossible to find JavaScript errors in cshtml files at compile-time, rather than at run-time.

JavaScript code is scattered around ts and cshtml files, which makes code splitting and dynamic imports difficult. Now that we are using Webpack through Laravel Mix (#5 and #540, powered by ReMikus), we can easily make use of code splitting in React. See also #872.

The jQuery and jQuery UI packages cannot be upgraded easily, because there seem to be some breaking changes. This is why #675 and #679 cannot be merged.

It requires boilerplate code to translate user interfaces. In the current implementation, we need to

  1. create/edit a resx file
  2. update ResourcesApiController if needed
  3. create a ResourceRepository and pass it to a viewmodel
  4. create a ResourcesManager with the repository and current UI culture.
  5. load resources

, which is a lot of pain. By using i18next and react-i18next, we can make this process a lot easier.

We have two different libraries for the same thing, for example marked and MarkdownSharp (#38 and #904).

Why React?

There are several reasons why I chose React, but the main reasons are that

  1. React is developed and maintained by Facebook and a community of individual developers and companies.
  2. React is used by DeviantArt, Discord, Mastodon and MusicBrainz.
  3. TypeScript supports JSX.
  4. I like the React way of thinking (one-way data flow, function components, JSX and etc.).
  5. There is a way to integrate with other libraries.
  6. Using create-react-app is optional.
  7. We are still using customized Bootstrap 2 and this could be replaced with react-bootstrap.

I decided to use MobX, not Redux, for state management. This is because MobX API is surprisingly similar to Knockout's. The conversion shouldn't be that hard, although there are subtle differences in behavior between them (e.g. subscribe and reaction).

Of course this would be nearly impossible to do all at once, it has to be done gradually.

Examples

Before:

<div class="label label-info" data-bind="click: function() { $parent.advancedFilters.filters.remove($data); }">

Who is the $parent in this context?

After:

<div
    className="label label-info"
    onClick={(): void => advancedFilters.remove(filter)}
>
@ycanardeau ycanardeau added complexity-epic frontend Presentation layer (visible to user) React JavaScript library: React labels Jul 3, 2021
@ycanardeau ycanardeau added this to the React conversion milestone Jul 3, 2021
@ycanardeau ycanardeau self-assigned this Jul 3, 2021
@ycanardeau ycanardeau pinned this issue Jul 3, 2021
@ycanardeau ycanardeau unpinned this issue Mar 28, 2023
@ycanardeau ycanardeau removed their assignment Mar 29, 2023
@andreoda andreoda added complexity: high 7 to 30 days of work (or longer), consider splitting and removed complexity: epic labels Apr 22, 2023
@andreoda andreoda pinned this issue May 8, 2023
@FinnRG FinnRG closed this as completed Jul 26, 2023
@FinnRG FinnRG unpinned this issue Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: high 7 to 30 days of work (or longer), consider splitting frontend Presentation layer (visible to user) React JavaScript library: React
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants