Comments (1)
Hey @AFK-Python!
You should be able to share state without DOM tricks by using React context, defining a provider using the root
configuration. Something like:
import { createContext, useContext, useState } from "react";
const context = createContext({
counter: 0,
setCounter: (value: number) => {},
});
const { Provider } = context;
const config = {
root: {
render: ({ children }) => {
const [counter, setCounter] = useState(0);
return <Provider value={{ counter, setCounter }}>{children}</Provider>;
},
},
components: {
MyComponent: {
render: () => {
const { counter, setCounter } = useContext(context);
return (
<>
<div>Clicked {counter} times</div>
<button onClick={() => setCounter(counter + 1)}>Click me</button>
</>
);
},
},
},
};
Let me know if that works! Going to close the issue.
from puck.
Related Issues (20)
- Feature request: Allow mapRow to return more than just string and number types HOT 1
- dragging the component from the left side. its not going back to original position HOT 5
- Load and show live data on client side HOT 1
- Is there any way to load the live data or server side rendering of data live data HOT 1
- resolveData is not called when a component is placed in the editor HOT 1
- Feature request: Override left and right sidebars HOT 1
- History type not exported
- Expose `setHistories` and `setHistoryIndex`
- Feature request: DropZones support horizontal direction HOT 1
- Scroll Animation Not working inside puck editor HOT 1
- Adding Card Previews on Hover HOT 2
- Move drop zone content when reordering array items HOT 1
- an option to make fields required
- an option to localize the sections names HOT 2
- Update default type of `FieldLabel` to `div` instead of `label` HOT 2
- make drawer component drop in the right side instead of the left side if the document dir is rtl HOT 1
- Type error when trying to conditionally show fields using resolveFields HOT 1
- Feedback HOT 1
- Add support for handlers to react to internal state changes.
- Add label property to search button in 'external' input
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 puck.