preact-compat | : raised_hands : React compatibility layer for Preact | Frontend Framework library
kandi X-RAY | preact-compat Summary
kandi X-RAY | preact-compat Summary
:raised_hands: React compatibility layer for Preact.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a component hook to a component instance
- Handle props
- Normalizes an event .
- Replace a child component with a parent .
- Clones an element .
- Normalizes virtual nodes .
- Create multiple hooks
- Upgrade vnodes to vNodes
- wrap stateless component
- Sanitize virtual nodes
preact-compat Key Features
preact-compat Examples and Code Snippets
Community Discussions
Trending Discussions on preact-compat
QUESTION
I created a Preact app using the preact-cli, and need to add react-router-dom
to my project for routing. How can I add react-router to the project without ejecting the app, in order to install the router library?
I've seen options for adding webpack, but that' requires ejecting the app.
I added "preact-compat": "^3.19.0",
to my package.json in the project, but not sure how to either add webpack or import the necessary react-router imports:
import {BrowserRouter as Router, Route, Switch, NavLink} from 'react-router-dom';
ANSWER
Answered 2021-Nov-20 at 01:09but that' requires ejecting the app
There is no way to "eject" from preact-cli
. That isn't functionality that exists, so I'm a bit confused on what it is that you're referring to.
We make the entire config available to you through your preact.config.js
. With this, you can configure absolutely any part of the Webpack config that you'd like, and only those bits. You don't need to do anything like CRA's eject, where you have to now own the entire config yourself. You can edit the pieces you want, and leave everything else out of site & out of mind.
I've seen options for adding webpack
preact-cli
uses Webpack for bundling, it's the fundamental underlying tool. There's no way to use it without Webpack, so this doesn't make much sense.
I added
"preact-compat": "^3.19.0"
Remove this. preact-cli
already adds compat, and does it from the correct source.
If you read the docs for preact-compat
, you'll see it's only for Preact 8.x and prior, which is a few years out-of-date at this point. The correct compat package for v10+ is preact/compat
. We set this up for you already in preact-cli
though, so nothing you need to do yourself.
Why do you think you need to do any configuration just to import the library? Did you run into any errors, or maybe docs that are confusing/misworded? Just ran a test with v6, should work out-of-the-box after you swap it in for preact-router
(assuming you've set up a preact-cli
project using one of our templates)
QUESTION
Dont use the guide I linked, it is old- use the one in the answer instead
I am attempting to switch from react to preact by following their guide. I change webpack.config.js alias to add:
...ANSWER
Answered 2021-Apr-06 at 06:07It looks like you were referring to a dated documentation page. Here is the latest one.
Your should use preact/compat
instead:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install preact-compat
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page