Comments (4)
I found I also needed to update theme imports e.g:
- const theme = require('prism-react-renderer/themes/github')
+ const theme = require('prism-react-renderer').themes.github
from prism-react-renderer.
Change module imports
- import Highlight, { defaultProps } from "prism-react-renderer";
+ import { Highlight } from "prism-react-renderer"
const Content = (
- <Highlight {...defaultProps} code={exampleCode} language="jsx">
+ <Highlight code={exampleCode} language="jsx">
Check language support
By default prism-react-renderer only includes a base set of languages that Prism supports. Depending on your app's build system you may need to await the import or use require to ensure window.Prism exists before importing the custom languages.
See: https://github.com/FormidableLabs/prism-react-renderer#custom-language-support
Install prismjs
(if not available yet):
# npm
npm install --save prismjs
# yarn
yarn add prismjs
# pnpm
pnpm add prismjs
Add language component:
import { Highlight, Prism } from "prism-react-renderer";
(typeof global !== "undefined" ? global : window).Prism = Prism
await import("prismjs/components/prism-applescript")
/** or **/
require("prismjs/components/prism-applescript")
from prism-react-renderer.
Change module imports
- import Highlight, { defaultProps } from "prism-react-renderer"; + import { Highlight } from "prism-react-renderer" const Content = ( - <Highlight {...defaultProps} code={exampleCode} language="jsx"> + <Highlight code={exampleCode} language="jsx">Check language support
By default prism-react-renderer only includes a base set of languages that Prism supports. Depending on your app's build system you may need to await the import or use require to ensure window.Prism exists before importing the custom languages.
See: https://github.com/FormidableLabs/prism-react-renderer#custom-language-support
Install
prismjs
(if not available yet):# npm npm install --save prismjs # yarn yarn add prismjs # pnpm pnpm add prismjsAdd language component:
import { Highlight, Prism } from "prism-react-renderer"; (typeof global !== "undefined" ? global : window).Prism = Prism await import("prismjs/components/prism-applescript") /** or **/ require("prismjs/components/prism-applescript")
so is this the whole migration guide?
from prism-react-renderer.
@RudraSen2 For me this was sufficient. Depending on the features you rely on this list could grow. Please provide an update if you needed to do some more tweaking.
from prism-react-renderer.
Related Issues (20)
- README.md link to supported langages broken (`includeLangs.js`) HOT 4
- Themes are missing in 2.0 release HOT 6
- TypeScript compile error: Cannot find module 'prismjs' or its corresponding type declarations HOT 2
- Prism type not assignable to PrismLib prop type HOT 1
- Import type PrismTheme
- Add JSON to the default included languages HOT 2
- Need python support HOT 1
- Import type Language HOT 4
- Default theme no longer working after upgrading to v2 HOT 2
- Theme : OneDark HOT 1
- Add types to languages HOT 1
- Highlight specific lines HOT 1
- Themes and other folders not included after npm install HOT 2
- Using Old Prism CSS Files HOT 3
- page fails to render HOT 1
- Prime trender
- Leading spaces ignored for the first line HOT 1
- Unable to start demo HOT 2
- Request to expose internal methods HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prism-react-renderer.