Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

Commit 9fd0644

Browse files
author
Chuck Kosman
committed
Render experience
1 parent b790444 commit 9fd0644

3 files changed

Lines changed: 39 additions & 52 deletions

File tree

App.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ export default function App() {
2424
},
2525
};
2626
},
27-
// @ts-ignore
28-
onLog: (...args) => {
29-
console.log(...args);
30-
},
31-
// @ts-ignore
32-
onError: (...args) => {
33-
console.error(...args);
34-
},
27+
// // @ts-ignore
28+
// onLog: (...args) => {
29+
// console.log(...args);
30+
// },
31+
// // @ts-ignore
32+
// onError: (...args) => {
33+
// console.error(...args);
34+
// },
3535
});
3636
}, []);
3737
return (

components/HeroList.jsx

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import React from 'react';
2-
import {Image, StyleSheet, Text, FlatList} from 'react-native';
2+
import {Image, StyleSheet, Text, FlatList, View} from 'react-native';
33
import {SafeAreaView} from 'react-native-safe-area-context';
44
import {parseExperiences} from '../lib/experiences';
5-
import {Experience} from '@ninetailed/experience.js-react';
5+
import {useExperience, Experience} from '@ninetailed/experience.js-react';
66

77
const styles = StyleSheet.create({
8-
container: {
9-
flex: 1,
10-
padding: 24,
11-
},
12-
blogPost: {
13-
marginBottom: 28,
14-
},
15-
coverImage: {
16-
marginBottom: 16,
8+
hero: {
9+
marginTop: 28,
1710
},
1811
image: {
1912
height: 100,
@@ -24,40 +17,43 @@ const styles = StyleSheet.create({
2417
fontSize: 20,
2518
marginBottom: 8,
2619
},
27-
excerpt: {
28-
fontSize: 16,
29-
color: 'grey',
30-
},
3120
});
3221

33-
function Hero({item}) {
22+
function Hero({entry}) {
3423
return (
35-
<>
36-
<Text style={styles.title}>{item.fields.internalName}</Text>
24+
<View style={styles.hero}>
25+
<Text style={styles.title}>{entry.fields.internalName}</Text>
3726
<Image
3827
style={styles.image}
39-
source={{uri: `https:${item.fields.image.fields.file.url}`}}
28+
source={{uri: `https:${entry.fields.image.fields.file.url}`}}
4029
/>
41-
</>
30+
</View>
4231
);
4332
}
4433

45-
// TODO: Change <Experience> to not use divs
34+
function HeroExperienceWrapper({item}) {
35+
return <HeroExperience item={item} />;
36+
}
37+
4638
function HeroExperience({item}) {
47-
console.log('item', item);
48-
const parsedExperiences = parseExperiences(item);
49-
console.log('experiences', parsedExperiences);
50-
return (
51-
<Experience
52-
item={item}
53-
id={item.sys.id}
54-
experiences={parsedExperiences}
55-
component={Hero}
56-
/>
57-
);
39+
const baseline = {
40+
...item,
41+
id: item.sys.id,
42+
};
43+
const {loading, variant} = useExperience({
44+
baseline,
45+
experiences: parseExperiences(item),
46+
});
47+
if (loading) {
48+
return <Text>Loading...</Text>;
49+
}
50+
if (variant) {
51+
return <Hero entry={variant} />;
52+
}
53+
return <Hero entry={baseline} />;
5854
}
5955

60-
export default function HeroPostList({entries}) {
56+
export default function HeroList({entries}) {
6157
return (
6258
<SafeAreaView>
6359
<Text>
@@ -67,7 +63,7 @@ export default function HeroPostList({entries}) {
6763
<FlatList
6864
data={entries}
6965
keyExtractor={item => item.sys.id}
70-
renderItem={Hero}
66+
renderItem={HeroExperienceWrapper}
7167
/>
7268
</SafeAreaView>
7369
);

lib/experiences.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ export const parseExperiences = (entry: singularBlock) => {
2222
return hasExperiences(entry)
2323
? entry.fields.nt_experiences
2424
.filter(experience => ExperienceMapper.isExperienceEntry(experience))
25-
.map(experience =>
26-
ExperienceMapper.mapCustomExperience(experience, variant => {
27-
return {
28-
id: variant.sys.id,
29-
item: {
30-
...variant,
31-
},
32-
};
33-
}),
34-
)
25+
.map(experience => ExperienceMapper.mapExperience(experience))
3526
: [];
3627
};

0 commit comments

Comments
 (0)