Answer the question
In order to leave comments, you need to log in
What to use for global memory in Laravel Mix + React?
Hi all.
I am making part of the program in Laravel. I use the react preset in the Laravel framework.
Those who are familiar know that there is such an entry point in the Laravel Mix preset
require('./bootstrap');
require('./components/FirstComponent');
require('./components/SecondComponent');
import React from 'react';
import ReactDOM from 'react-dom';
function FirstComponent(){
return(<div></div>)
export default FirstComponent;
if (document.getElementById('FirstComponent')) {
ReactDOM.render(
<FirstComponent/>, document.getElementById("FirstComponent"));
}
import { createStore } from 'redux';
import allReducers from '../reducers';
export const store = createStore(allReducers);
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { store } from '../classes/ReduxStore';
function FirstComponent(){
return(<div></div>)
export default FirstComponent;
if (document.getElementById('FirstComponent')) {
ReactDOM.render(
<Provider store={store}>
<FirstComponent/>
</Provider>, document.getElementById("FirstComponent"));
}
Answer the question
In order to leave comments, you need to log in
I haven’t worked with Laravel, and I’ve never come across such a partition, but if you need global data storage, why not look towards the context? You get the ability to use the context in different components with the same data set. It is enough to declare it at the top level. https://ru.reactjs.org/docs/hooks-reference.html#u
... Perhaps I did not fully understand your task, so I do not pretend to be the truth =)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question