From 04fe6fb39d1e3bd590d13d5bb770a3c2e89a4edd Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Fri, 7 Jul 2017 00:08:48 +0000 Subject: [PATCH] Don't call setState if unmounted before font loads fbshipit-source-id: 2ff8070 --- createIconSet.js | 13 ++++++++----- package.json | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/createIconSet.js b/createIconSet.js index 3d834f7..be57327 100644 --- a/createIconSet.js +++ b/createIconSet.js @@ -1,10 +1,8 @@ import React from 'react'; import { Text } from 'react-native'; import { Font } from 'expo'; -import createIconSet - from './vendor/react-native-vector-icons/lib/create-icon-set'; -import createIconButtonComponent - from './vendor/react-native-vector-icons/lib/icon-button'; +import createIconSet from './vendor/react-native-vector-icons/lib/create-icon-set'; +import createIconButtonComponent from './vendor/react-native-vector-icons/lib/icon-button'; export default function(glyphMap, fontName, expoAssetId) { const expoFontName = Font.style(fontName, { @@ -22,12 +20,17 @@ export default function(glyphMap, fontName, expoAssetId) { }; async componentWillMount() { + this._mounted = true; if (!this.state.fontIsLoaded) { await Font.loadAsync(font); - this.setState({ fontIsLoaded: true }); + this._mounted && this.setState({ fontIsLoaded: true }); } } + componentWillUnmount() { + this._mounted = false; + } + setNativeProps(props) { if (this._icon) { this._icon.setNativeProps(props); diff --git a/package.json b/package.json index fd7a5fc..63db4ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expo/vector-icons", - "version": "5.0.0", + "version": "5.1.0", "description": "Built-in support for 10 popular icon fonts and the tooling to create your own Icon components from your font and glyph map. This is a wrapper around react-native-vector-icons to make it compatible with Expo.", "main": "index.js", "scripts": {},