Comments (3)
In your example, the components don't exist at the same time, so when you call the sendReparentable method it has no effect. You should get a warning, if you don't get it I'll have to investigate why.
To do what you ask, you have to manually remove the child from a parent, mount the new parent and insert the child into it.
You can do this with the ReparentableMap or with another component other than the .
const {Reparentable, ReparentableMap} = createReparentableSpace();
// Mount ParentA...
let ParentA = ReparentableMap.get("A"); // The Parent instance of the <Reparentable id="A">
let Child = ParentA.removeChild("ChildKey");
// Unmount ParentA...
// Mount ParentB...
let ParentB = ReparentableMap.get("B");
ParentB.addChild(Child, position);
from react-reparenting.
A codesandbox example with for example a integration with react-router would really help, especially since the ReparentableMap is not mentioned in the react-reparenting docs (as far as i can see).
@mnikn did you end up using react-reparenting for your use-case? Do you happen to have a full example?
from react-reparenting.
I end up using react-reparenting, instead I try to rewrite my need reparenting component by pure dom js, and use dom api appendChild
to move it.
from react-reparenting.
Related Issues (14)
- Not working with audio element/component? HOT 2
- Breaking on 0.17 HOT 1
- Break with error on build production HOT 9
- Invariant: Invariant failed HOT 3
- React v17 support? HOT 2
- Can't access the examples HOT 2
- Usage for a slot like approach HOT 1
- Feature Request: Make library declarative HOT 1
- React error after reparenting HOT 1
- React v18? HOT 1
- Any ideas on where to start for react-native support HOT 12
- Typescript errors on import HOT 2
- Any way we can set new classes or props for the child when it's re-parented to other parent ? HOT 1
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 react-reparenting.