I would like to store data for select lists in my react app:
I have a js file:
export default {
views: [
{
month: 1,
year: 0,
day: 2
}
]
};
How can I import this into my react component so I can use it for lookups?
import views from '../config/views.js';
Something like this:
onChange(e) {
this.props.actions.navigate(views[e]);
Any ideas?
What is happening here is that you are exporting an object with a views property on it, to access it you would need to do: views.views[e].
If you want to see what's going on just: console.log(views).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.