for various reasons, my workplace is currently trying to introduce React/Redux into our project. Our project utilizes Shopify and it's Liquid templates along with jQuery. They want to migrate towards React, and we have thus far been injecting React by looking for specific ID's and injecting React Components in that way.
Due to this, and because we are now needing a store to keep and render data, I've come to a strange issue. If I wrap each one of these injected components with a Provider and store, I can essentially have each component with it's own store, but that doesn't help at all as it's pretty much mimicking local state.
Is there a way for me to 'connect' and share the store with multiple components?
I thought about wrapping the whole project, as is usually the case, but doing so would/should render the Liquid useless.
Here's an example of what's going on:
import ReactDOM from "react-dom";
import React from "react";
import attrToProps from "../../../partials/data-attribute-to-props.js";
import FavoritesToggler from "./index.js";
import store from "./../../Store/store"
import { Provider } from "react-redux"
const rootEl = document.getElementById("fav-container-react");
if(rootEl) {
const props = attrToProps(rootEl.attributes);
rootEl && ReactDOM.render(<Provider store={store}><FavoritesToggler {...props} /></Provider>, rootEl);
}
This is injected into a div that contains the 'fav-container-react' id.
But we have several of these at the moment, and I'm wondering how to get them to connect all to the same store.
Any ideas would be appreciated, including perhaps a possible change in architecture (we're required to 'show progress' in order to continue getting funded, so starting a new project isn't an option. Meaning I need a solution that is able to continuously update legacy code to React)