How to use MDX in React-Native to great effect and the challenges you didn't know you signed up for.
This talk has been presented at React Advanced 2021, check out the latest edition of this React Conference.
How to use MDX in React-Native to great effect and the challenges you didn't know you signed up for.
This talk has been presented at React Advanced 2021, check out the latest edition of this React Conference.
To ensure security, developers should only use trusted content with the MDX runtime, as it executes MDX strings that can contain executable JavaScript. It's crucial to verify the source of the MDX content to prevent potential security risks.
The RnMDX library is a solution for using MDX in React Native applications. It provides Markdown components specifically designed for React Native, supports dynamic content rendering, and can be used with the MDX runtime or through precompilation of MDX into JavaScript.
Originally, MDX was not supported directly in React Native due to differences in handling components. However, with the development of tools like RnMDX, it is now possible to use MDX in React Native by either running MDX content at runtime or precompiling it into JavaScript components.
The main challenges include adapting Markdown components to work within the React Native environment, which does not recognize standard HTML tags, and ensuring consistent styling and functionality across different devices and platforms.
MDX is a technology that combines Markdown and JSX, allowing developers to embed React components within Markdown content. This enables more dynamic and interactive web content, blending simple text formatting with complex HTML and JavaScript functionality.
MDX can be used to create interactive and engaging content for mobile apps, such as dynamic articles, educational content, or interactive tutorials. It allows for the integration of multimedia components and custom interactive elements directly within the content.
Hi, I'm Daniel, a freelance full stack JavaScript developer from Finland. I build web apps from scratch to production, including UI, back end, API integration, databases, and servers. I also build React Native apps. This talk is about something I developed, challenges I faced, and the solution I put on NPM. MDX is a combination of Markdown and JSX. Markdown is a simple and standardized tool for creating formatted text, while JSX takes HTML to the next level. I took the leap and tried React.
Hi, I'm Daniel, a freelance full stack JavaScript developer from Finland. My definition of full stack is that I build web apps from scratch to production, meaning the UI and the styling thereof, back end with node, API integration, databases, servers, you name it.
I also build React Native apps and I continue to be amazed at how well my existing web experience can be applied in that area. It's such a normal thing to use a JavaScript or react specific library in React Native that instances where it isn't possible stand out.
Ah, good old NPM, the holy land of JavaScript developers, where I can usually find a package for whatever I need to do. NPM provides nice reusable solutions for sole challenge so that I can focus on the business logic, you know, what the app actually needs to do, without getting into the weeds of developing custom state managers or routers or styling solutions or whatever. But what if the thing you need doesn't exist on NPM? This is a talk about something which I took for granted to exist, but was rude enough to not exist. The solution I developed, and the challenges I ran into along the way. And of course, I put it on NPM.
MDX is in the title of this talk, so what is MDX? It is a combination of two technologies, Markdown and JSX. I realize these two may be very familiar to this audience, but let's take a look at the strengths they each bring to the table, and imagine what a team might look like.
Content is king. And the ability to create and display content is hugely important for any application. If your content is text-based, Markdown is a great tool to use, as it provides everything you need while being very simple and easy to pick up for anyone. With Markdown, you can write formatted text anywhere that accepts keyboard input. You don't need specialized word processing software for that anymore. Markdown is readable for humans as it is, but to actualize that formatting, you just need a Markdown renderer. Markdown is standardized, and has been around for a while, so there are lots of libraries available for probably all programming languages and platforms. Markdown is almost as easy to render, at least to write, due to again, being just plain text. Nowadays, we expect Markdown to be supported, and it feels as if that just happened overnight. One day, we had as many formatting languages as there were apps with text areas, and the next day, Markdown was everywhere. Of course, people have worked hard on this, but it shows how important it was to unify and standardize these simple formatting features and how badly it was needed.
I probably don't need to go into why React is great, since I'm speaking at a conference called React Advanced, but I do want to touch on JSX, which React introduced and popularized. Whereas Markdown simplified text formatting and made HTML unnecessary for these use cases, JSX takes HTML to the next level. When I got into programming, mixing HTML and JavaScript was a no-no. It was taboo, since these were separate concerns. You had your HTML, which you decorated with styles and scripts. Never the twain shall meet. When I first saw JSX, it was horrifying, since it went against everything I had learned until that point. But I took the leap and tried React.
JSX enables declarative code and a composition-based architecture, making it easy to compose self-contained components. HTML is static and not enough for modern applications. JSX allows for dynamic UIs without the need for server-side rendering or manipulating static HTML with JavaScript or JQuery.
And I haven't looked back since. JSX enables declarative code and a composition-based architecture, where the structure of the application is involved in the business logic as a first-class citizen, rather than something separate and disconnected, which you need to surgically modify in order for it to reflect the current state of your app.
HTML is static and is by itself not enough for modern applications. Attempts have been made to make it more dynamic, some more successful than others. Server-side HTML rendering does work quite nicely, but once the markup arrives in the browser, it is still static and asking the server to do updates which the client could do much easier and faster is a user experience that smells and tastes like the 90s. And when you try to manipulate static HTML with JavaScript or JQuery, it quickly turns into a game of Jenga with way too many people moving blocks around simultaneously.
In contrast, JSX makes it easy to compose self-contained components that include the logic, styling and layout that they need to accomplish their task. The UI is a product of the state and not something the developer needs to attend to separately. UIs can be quite complex without it all falling apart.
We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career
Comments