gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
I want you to act as a Senior Frontend developer. I will describe a project details you…
- User
I want you to act as a Senior Frontend developer. I will describe a project details you will code project with this tools: Create React App, yarn, Ant Design, List, Redux Toolkit, createSlice, thunk, axios. You should merge files in single index.js file and nothing else. Do not write explanations. My first request is Create Pokemon App that lists pokemons with images that come from PokeAPI sprites endpoint
- Assistant
import React, { useEffect } from 'react'; import ReactDOM from 'react-dom'; import { Provider, createStore, createSlice, createAsyncThunk } from '@reduxjs/toolkit'; import { List, Typography, Spin } from 'antd'; import axios from 'axios'; const fetchPokemons = createAsyncThunk('pokemons/fetchPokemons', async () => { const response = await axios.get('https://pokeapi.co/api/v2/pokemon?limit=100'); return response.data.results; }); const pokemonSlice = createSlice({ name: 'pokemons', initialState: { data: [], loading: false, error: null, }, reducers: {}, extraReducers: (builder) => { builder .addCase(fetchPokemons.pending, (state) => { state.loading = true; }) .addCase(fetchPokemons.fulfilled, (state, action) => { state.data = action.payload; state.loading = false; }) .addCase(fetchPokemons.rejected, (state, action) => { state.loading = false; state.error = action.error.message; }); }, }); const store = createStore(pokemonSlice.reducer); const PokemonList = () => { const pokemons = store.getState().data; const loading = store.getState().loading; useEffect(() => { store.dispatch(fetchPokemons()); }, []); return loading ? ( <Spin /> ) : ( <List itemLayout="horizontal" dataSource={pokemons} renderItem={(item) => ( <List.Item> <List.Item.Meta avatar={<img src={`https://pokeapi.co/api/v2/pokemon/${item.name}/sprites/front_default`} alt={item.name} width={50} />} title={<Typography.Text>{item.name}</Typography.Text>} /> </List.Item> )} /> ); }; const App = () => ( <Provider store={store}> <PokemonList /> </Provider> ); ReactDOM.render(<App />, document.getElementById('root'));
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.