I want to have some object to be accessible from multiple components, the same object, and those components are independent of each other.
It looks like Redux isn't the right way and this: React native- Best way to create singleton pattern doesn't really answer the question.
Is there another way?
答案 0 :(得分:0)
Well, I'm not sure this is right way but I usually do this way through module.
// config.js
export default {
data1: 'data1',
data2: 'data2',
...
}
// from components
import Config from './config' // You can do this easier with @providesModule
...
config.data1 // you now access & modify common datas like this