简体   繁体   中英

Importing data via .json into react native with Redux

I made a workout app and I'm using Redux to save all of the sets and workouts. Right now I hand typed all of exercises into Redux data to test things out. I have all of the exercises in a .json file and I wanted to import it into the app so users would have access to them.

Would I need to import the .json file into Redux or different part of the app and then somehow give redux access to them? I confused because users would select the exercises and they can add descriptions, change number of sets and reps (which are all in Redux).

Edit

I'm new to coding hence why I haven't gone through the api route. I just want to get the beta version out. Also they are thousands of exercises in that .json file and that's why I haven't manually entered them into Redux.

您可以像这样读取本地 JSON 文件,然后像访问普通 JS 对象一样访问锻炼数据

const exerciseData = require('./exerciseData.json');

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM