plan-and-done-for-may-06-2018
What will I learn today?
FreeCodeCamp React projects: Markdown online parser - start coding.
Done
Online markdown editor app
The user story and the desired result.
Challenges
- Estimated size of the bundle over 50kB gzipped.
- How to make browsersync work with react application?
- Can't make work webpack hot reload with gulp.
- How to render escaped HTML inside component?
Solutions
-
Explanation from Dan Abramov. Google for solution alternatives.
-
The problem looks like:
react-hot-loader\index.js' is not a loader (must have normal or pitch function)
To solve it we need to move
react-hot-loaderfrom webpack.config.js to .babelrc as described in Dan's post (check step 3.2.a).Second problem with dependencies of eslint and depricated rule
jsx-a11y/href-no-hash. Solved it including to rules into .eslintrc -"jsx-a11y/href-no-hash": 2, "jsx-a11y/anchor-is-valid": 2;Third problem is the working server doesn't produce bundle.js. But as I've got it's not a bug but a feature - webpack doesn't generate output when it runs in with devServer.
Fourth problem is server does rebuild, but after checking for update and finding the updated module doesn't hot reload react components saying:
App is up to date.
Solved it after a couple of hours by reading different issues (#581 and #100 gave me a clue) and finally using manual of react-hot-reload. I've exported all my components as hot.
-
I've got escaped HTML result of a markdown converter function. When I tried to put the result into an output component on the page I got raw HTML on the page. The way to convert it into renderable HTML is to use weird function
dangerouslySetInnerHTMLas described on SO page . Here is a bit about the function name and sense begind it.