-
Notifications
You must be signed in to change notification settings - Fork 249
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
issue/2824-jsx Changed bundler and added React support #2829
Conversation
Great work! |
* @param {string} html | ||
*/ | ||
export function html(html, ref = null) { | ||
let node = html ? HTMLReactParser(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.
As discussed, please fix when undefined
is passed.
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.
done in 9b3a7b0
src/core/js/reactHelpers.js
Outdated
* @param {...any} args List of classes | ||
*/ | ||
export function classes(...args) { | ||
return args.filter(Boolean).join(' '); |
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.
Could this accept an array?
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.
done in 9b3a7b0
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.
updated core classes to match in 327a793
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.
code 👍
testing 👍
@tomgreenfield Just waiting on you before I remove the page, article and block react templates. |
@olivermartinfoster per our 16/09 chat, |
Will rebase this against #2923 once that pr is accepted |
Replaced with #2963 |
#2824
Will provide an almost seamless migration away from build-side requirejs and AMD modules to ES6 modules and add react support to the framework.
Facilitates
import
andexport
directivesvar Adapt = require('core/js/adapt');
etc will still work in the console and for other pluginsDownsides
js
folderconstructor
function without thenew
keyword is not allowed - which is an essential part of the way Backbone constructs classes.Added
<%= outputdir %>/.cache
to speed up compilation times--disable-cache
to disable the cache and recompile from scratchThese plugins achieve react templating and integration in the same way we have been doing with handlebars:
Removed
config.js
file has been moved to thejavascript
grunt task configFixed
QuestionView
has two differentreturn
statements, so cannot resolve to oneexport default
directiveTesting
Example
Shows fast compilation times,
import
/export
, debugging andrequire
functioning with an ES6 module in the client-side:Templates
Supports react 'templates' as near as I could get it to our current handlebars templates - separate, override-able etc. This change does not require a wholesale switch to React views but instead uses our current Backbone views and React as a templating engine. This means that some of the usual functionality of React views, such as the state object, aren't used to cause view re-render, instead the
this.changed()
function should be called to re-render a Backbone View with a React template.Here are a few reasons for using React as a templating engine only:
Usage
A React version of the accordion lives here pr / branch
You can see the core templates are using react versions https://github.com/adaptlearning/adapt_framework/tree/issue/2824-jsx/src/core/templates which means you can update the models for page, article and block on the fly and the views will update on the page:
Release note
Remove
page.jsx
,article.jsx
andblock.jsx
before merging as these are likely to have larger impacts on course content that should be avoided in the short-term. We should aim for component level react views to start.