https://github.com/snowfluke/react-native-jsx-parser
Modified JSX Parser to parse JSX string in React Native
https://github.com/snowfluke/react-native-jsx-parser
jsx-parser react-native
Last synced: 2 months ago
JSON representation
Modified JSX Parser to parse JSX string in React Native
- Host: GitHub
- URL: https://github.com/snowfluke/react-native-jsx-parser
- Owner: snowfluke
- Created: 2021-05-28T11:12:26.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-11T09:00:49.000Z (over 1 year ago)
- Last Synced: 2026-01-02T12:37:19.892Z (5 months ago)
- Topics: jsx-parser, react-native
- Language: JavaScript
- Homepage:
- Size: 1.81 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-jsx-parser
Modified JSX Parser to parse JSX string in React Native
# Install
> npm i react-native-jsx-parser --save
# Install Dependencies
- [JsxParser](https://www.npmjs.com/package/react-jsx-parser) by troyalford
> npm i react-jsx-parser --save
# Usage
```js
// Use import or require()
import RNJsxParser from 'RNJsxParser';
// Import all the components needed in the string
// Example:
import { PostCard, CommentCard } from './customComponents'
// Define the components objects
const postComponents = { PostCard, CommentCard }
// Define the bindings if you have
const postBindings = { lorem: 'ipsum', handleEvent: () => { /* */ } }
// The Jsx String, you could also store and fetch from JSON file
// Just remember to wrap with React Fragment <> >
const stringJsx = '<> Hello >'
```
# Props
Props is all the same as react-jsx-parser, but only allow 3 props `bindings`, `components` and `jsx`. You could use other props by editing the file inside node_modules/react-native-jsx-parser.
See the available react-jsx-parser [Here](https://www.npmjs.com/package/react-jsx-parser)