How to get state from plugin's redux in controlPanel? #32169
Replies: 2 comments 2 replies
-
Hey @nick-shaydayuk! I'm here to help you with any bugs, questions, or contributions you have. If you need assistance, feel free to ask! To access the Redux state from a plugin in the control panel, you can use the import { useSelector } from 'react-redux';
const MyComponent = () => {
const myPluginState = useSelector((state) => state.myPlugin);
// Use myPluginState as needed
return <div>{JSON.stringify(myPluginState)}</div>;
}; In this example, replace Additionally, if you need to map state to props in a more traditional way, you can use the import { connect } from 'react-redux';
const mapStateToProps = (state) => ({
myPluginState: state.myPlugin,
});
const MyComponent = ({ myPluginState }) => {
// Use myPluginState as needed
return <div>{JSON.stringify(myPluginState)}</div>;
};
export default connect(mapStateToProps)(MyComponent); This method is useful if you prefer to keep your component as a class component or if you want to separate the logic of mapping state to props from the component itself. For saving user settings and ensuring they persist across page reloads, consider using middleware like To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu |
Beta Was this translation helpful? Give feedback.
-
Hi! Can anyone suggest best practices for using the control panel in conjunction with plugins?
While developing a plugin, I encountered the problem that I can't get data from my plugin's redux in the panel.
(The plugin I want to connect uses redux to manage its state) The data is needed so that I can save user settings when the page is reloaded. For example, Preset has a plugin with an interactive table, where the required functionality is implemented.
Any help/suggestions or links would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions