MCPcopy Create free account
hub / github.com/adobe/react-spectrum / reducer

Function reducer

packages/@react-spectrum/s2/src/Image.tsx:153–180  ·  view source on GitHub ↗
(state: State, action: Action)

Source from the content-addressed store, hash-verified

151}
152
153function reducer(state: State, action: Action): State {
154 switch (action.type) {
155 case 'update': {
156 return {
157 state: 'loading',
158 src: action.src,
159 startTime: Date.now(),
160 loadTime: 0
161 };
162 }
163 case 'loaded':
164 case 'error': {
165 return {
166 ...state,
167 state: action.type
168 };
169 }
170 case 'revealed': {
171 return {
172 ...state,
173 state: 'revealed',
174 loadTime: Date.now() - state.startTime
175 };
176 }
177 default:
178 return state;
179 }
180}
181
182const wrapperStyles = style({
183 backgroundColor: 'gray-100',

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected