-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to send selection nodes name to app.tsx #6
How to send selection nodes name to app.tsx #6
Comments
import * as Networker from "monorepo-networker";
import { NetworkSide } from "../sides";
import { keyframe } from "../../../type/types";
interface Payload {
keyframes: {
[key:string]: keyframe[]
};
allowPlay: boolean;
}
export class SelectionMessage extends Networker.MessageType<Payload> {
receivingSide(): Networker.Side {
return NetworkSide.UI;
}
handle(payload: Payload) {
//can only resolve the message here ↓↓↓
console.group('selection')
console.log(payload.allowPlay)
console.table(payload.keyframes);
console.groupEnd()
}
} |
Hey there! 😄 In theory, you can use a global store library (like Redux or Zustand) to store your data globally and initiate state updates outside a React component. Theoretically it'd look like so:
figma.on("selectionchange", () => {
const { selection } = figma.currentPage;
NetworkMessages.SELECTION_CHANGED.send({
selection: selection.map((selection) => ({
id: selection.id,
boundingBox: selection.absoluteBoundingBox,
})),
});
});
import { store } from "/path/to/createdStore";
interface Payload {
selection: {
id: string;
boundingBox: Rect | null;
}[];
}
export class SelectionMessage extends Networker.MessageType<Payload> {
receivingSide(): Networker.Side<any> {
return NetworkSide.UI;
}
handle(payload: Payload): void {
store.dispatch({
type: "SELECT",
payload,
});
}
} |
I might also want to support arbitrary subscriptions to the messages too. |
Thank you, using a global store library is better than my current method. I'll try this way to assign data from figma to plugin page. I also looking forward to the new feature, it seems to make the code concise and elegant. 😍 |
Hello, I am now in a situation of how to return the node name string selected by figma to the App.tsx page. So far, it seems that I can only handle this string information in the class under messages.
What if I want to return these strings to App.tsx and use setState to refresh the display of the page.
How should it be done according to the current structure?
The text was updated successfully, but these errors were encountered: