Closed jeongbaebang closed 2 months ago
import React from 'react'; import useMockData from './hooks/useMockData'; const App = () => { const { mockData, addItem } = useMockData({ schema: { user: { id: 'UUID', name: 'string', age: 'number', address: ['string', 'string'], profilePicture: 'image', registrationDate: 'date', isAdmin: 'boolean', inventory: { money: 'number', connectionUser: [ { userId: 'UUID', name: 'string', isActive: 'boolean', address: ['string', 'number'], }, ], }, }, }, options: { count: 5, // Initial number of mock data items type: { name: { min: 5, max: 15 }, number: { min: 1, max: 100 }, image: { width: { min: 400, max: 800 }, height: { min: 300, max: 600 }, }, date: { start: '2022-01-01', end: '2023-01-01', }, }, }, }); return ( <div> <h1>Mock Data Example</h1> <button onClick={addItem}>Add New Item</button> <ul> {mockData.map((item, index) => ( <li key={index}> <div> <strong>ID:</strong> {item.user.id} </div> <div> <strong>Name:</strong> {item.user.name} </div> <div> <strong>Age:</strong> {item.user.age} </div> <div> <strong>Address:</strong> {item.user.address.join(', ')} </div> <div> <strong>Profile Picture:</strong> </div> <img src={item.user.profilePicture} alt="Profile" style={{ width: '100px', height: '100px' }} /> <div> <strong>Registration Date:</strong>{' '} {item.user.registrationDate.toDateString()} </div> <div> <strong>Admin:</strong> {item.user.isAdmin ? 'Yes' : 'No'} </div> <div> <strong>Inventory:</strong> </div> <div> <strong>Money:</strong> {item.user.inventory.money} </div> <div> <strong>Connection Users:</strong> </div> <ul> {item.user.inventory.connectionUser.map( (connection, connIndex) => ( <li key={connIndex}> <div> <strong>User ID:</strong> {connection.userId} </div> <div> <strong>Name:</strong> {connection.name} </div> <div> <strong>Active:</strong> {connection.isActive ? 'Yes' : 'No'} </div> <div> <strong>Address:</strong> {connection.address.join(', ')} </div> </li> ) )} </ul> </li> ))} </ul> </div> ); }; export default App;
πΎ Pull Request
1οΈβ£ Spec
2οΈβ£ λ³κ²½ μ¬ν
3οΈβ£ μμ μ½λ
4οΈβ£ κ΄λ ¨ λ¬Έμ (μ ν μ¬ν)