Last active
February 17, 2017 09:22
-
-
Save Temzasse/dee9d30a8e3e174ff2254dc906367ce2 to your computer and use it in GitHub Desktop.
React - "Cannot read property 'getNativeNode' of null" bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In GalleryItemContainer.js | |
componentWillMount() { | |
// some stuff here... | |
this.props.fetchGalleryItem(slug); | |
} | |
... | |
// In my sagas | |
function* fetchGalleryItem({ payload }) { | |
try { | |
const galleryItem = yield call(api.getGalleryItem, payload); | |
yield put(actions.receiveGalleryItem(galleryItem)); | |
} catch (err) { // <--- error was swallowed here | |
yield put(actions.failGalleryItem()); | |
} | |
} | |
... | |
// In GalleryItem.js component | |
renderGalleryImage(image, imageIdx) { | |
let url; | |
if (some_logic_here) { | |
url = 'something'; | |
} else { | |
url = image.url.source_url; // <--- image.url was undefined here which caused the error | |
} | |
return ( | |
<GalleryImage key={imageIdx}> | |
<GalleryImageInner | |
onClick={() => this.showLightBox(imageIdx)} | |
src={url} | |
/> | |
</GalleryImage> | |
); | |
} | |
render() { | |
return ( | |
<GalleryImages> | |
{images.map((image, idx) => this.renderGalleryImage(image, idx)} | |
</GalleryImages> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment