import { useState } from 'react'; import { useSelector } from 'react-redux'; import { RootState } from '../redux/store'; export default function TodoList() { // state from redux store const items = useSelector((state: RootState) => state.items); // normal state const [nextId, setNextId] = useState<number>(0); // proceed to use state as usual return ( <> {items.map(item => { return ( <TodoItem text={item.name} /> ) })} </> ) }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter