Font awesome icons are not displaying react
up vote
-1
down vote
favorite
I'm using font awesome and have imported it in index.js
import '././styles/fontawesome/css/fontawesome.min.css';
following in filter component
<span onClick={this.togglem.bind(this)}>
{/*<span className="rTitle">Filters</span>*/}
<i className="fa fa-filter" aria-hidden="true"></i>
</span>
Here, the icon fa-filter is not getting displayed can anyone lemme know whats going wrong
Using double dots its throws this exception .You attempted to import ../../../styles/fontawesome/css/fontawesome.min.css which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
structure is
src/filter.js
src/styles/fontawesome
version -5.5.0
i've imported in filter pointings are all right it show the css styles
when inspected but does not show the icon
reactjs font-awesome
add a comment |
up vote
-1
down vote
favorite
I'm using font awesome and have imported it in index.js
import '././styles/fontawesome/css/fontawesome.min.css';
following in filter component
<span onClick={this.togglem.bind(this)}>
{/*<span className="rTitle">Filters</span>*/}
<i className="fa fa-filter" aria-hidden="true"></i>
</span>
Here, the icon fa-filter is not getting displayed can anyone lemme know whats going wrong
Using double dots its throws this exception .You attempted to import ../../../styles/fontawesome/css/fontawesome.min.css which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
structure is
src/filter.js
src/styles/fontawesome
version -5.5.0
i've imported in filter pointings are all right it show the css styles
when inspected but does not show the icon
reactjs font-awesome
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm using font awesome and have imported it in index.js
import '././styles/fontawesome/css/fontawesome.min.css';
following in filter component
<span onClick={this.togglem.bind(this)}>
{/*<span className="rTitle">Filters</span>*/}
<i className="fa fa-filter" aria-hidden="true"></i>
</span>
Here, the icon fa-filter is not getting displayed can anyone lemme know whats going wrong
Using double dots its throws this exception .You attempted to import ../../../styles/fontawesome/css/fontawesome.min.css which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
structure is
src/filter.js
src/styles/fontawesome
version -5.5.0
i've imported in filter pointings are all right it show the css styles
when inspected but does not show the icon
reactjs font-awesome
I'm using font awesome and have imported it in index.js
import '././styles/fontawesome/css/fontawesome.min.css';
following in filter component
<span onClick={this.togglem.bind(this)}>
{/*<span className="rTitle">Filters</span>*/}
<i className="fa fa-filter" aria-hidden="true"></i>
</span>
Here, the icon fa-filter is not getting displayed can anyone lemme know whats going wrong
Using double dots its throws this exception .You attempted to import ../../../styles/fontawesome/css/fontawesome.min.css which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
structure is
src/filter.js
src/styles/fontawesome
version -5.5.0
i've imported in filter pointings are all right it show the css styles
when inspected but does not show the icon
reactjs font-awesome
reactjs font-awesome
edited Nov 10 at 16:02
asked Nov 10 at 13:40
Tested
1551216
1551216
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Your import looks wrong import '././styles/fontawesome/css/fontawesome.min.css';
you're probably looking for import '../../styles/fontawesome/css/fontawesome.min.css';
(pay attention to the dots).
If you're using React with JSX (you're most likely doing it) you need to use className
to define html class attribute:
<i className="fa fa-filter" aria-hidden="true"></i>
Also, the right way to use FontAwesome in React in documented here: https://fontawesome.com/how-to-use/on-the-web/using-with/react
dont work className too class also works n .. doesnt work its points outside src
– Tested
Nov 10 at 13:51
Can you share your project structure? The path to your CSS is wrong. Usingclass
would work but throw an error in React sinceclass is a reserved word in ES6+
, so always useclassName
.
– Davo
Nov 10 at 13:58
classname too doesnt apply FontAwesome. Ihave update my code
– Tested
Nov 10 at 14:01
According to your file structure, and assuming yourindex.js
file is in thesrc
folder too:import './styles/fontawesome/css/fontawesome.min.css';
– Davo
Nov 10 at 14:04
ya everything is in src as outside it doesnt support i have edited question
– Tested
Nov 10 at 14:12
|
show 3 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Your import looks wrong import '././styles/fontawesome/css/fontawesome.min.css';
you're probably looking for import '../../styles/fontawesome/css/fontawesome.min.css';
(pay attention to the dots).
If you're using React with JSX (you're most likely doing it) you need to use className
to define html class attribute:
<i className="fa fa-filter" aria-hidden="true"></i>
Also, the right way to use FontAwesome in React in documented here: https://fontawesome.com/how-to-use/on-the-web/using-with/react
dont work className too class also works n .. doesnt work its points outside src
– Tested
Nov 10 at 13:51
Can you share your project structure? The path to your CSS is wrong. Usingclass
would work but throw an error in React sinceclass is a reserved word in ES6+
, so always useclassName
.
– Davo
Nov 10 at 13:58
classname too doesnt apply FontAwesome. Ihave update my code
– Tested
Nov 10 at 14:01
According to your file structure, and assuming yourindex.js
file is in thesrc
folder too:import './styles/fontawesome/css/fontawesome.min.css';
– Davo
Nov 10 at 14:04
ya everything is in src as outside it doesnt support i have edited question
– Tested
Nov 10 at 14:12
|
show 3 more comments
up vote
1
down vote
Your import looks wrong import '././styles/fontawesome/css/fontawesome.min.css';
you're probably looking for import '../../styles/fontawesome/css/fontawesome.min.css';
(pay attention to the dots).
If you're using React with JSX (you're most likely doing it) you need to use className
to define html class attribute:
<i className="fa fa-filter" aria-hidden="true"></i>
Also, the right way to use FontAwesome in React in documented here: https://fontawesome.com/how-to-use/on-the-web/using-with/react
dont work className too class also works n .. doesnt work its points outside src
– Tested
Nov 10 at 13:51
Can you share your project structure? The path to your CSS is wrong. Usingclass
would work but throw an error in React sinceclass is a reserved word in ES6+
, so always useclassName
.
– Davo
Nov 10 at 13:58
classname too doesnt apply FontAwesome. Ihave update my code
– Tested
Nov 10 at 14:01
According to your file structure, and assuming yourindex.js
file is in thesrc
folder too:import './styles/fontawesome/css/fontawesome.min.css';
– Davo
Nov 10 at 14:04
ya everything is in src as outside it doesnt support i have edited question
– Tested
Nov 10 at 14:12
|
show 3 more comments
up vote
1
down vote
up vote
1
down vote
Your import looks wrong import '././styles/fontawesome/css/fontawesome.min.css';
you're probably looking for import '../../styles/fontawesome/css/fontawesome.min.css';
(pay attention to the dots).
If you're using React with JSX (you're most likely doing it) you need to use className
to define html class attribute:
<i className="fa fa-filter" aria-hidden="true"></i>
Also, the right way to use FontAwesome in React in documented here: https://fontawesome.com/how-to-use/on-the-web/using-with/react
Your import looks wrong import '././styles/fontawesome/css/fontawesome.min.css';
you're probably looking for import '../../styles/fontawesome/css/fontawesome.min.css';
(pay attention to the dots).
If you're using React with JSX (you're most likely doing it) you need to use className
to define html class attribute:
<i className="fa fa-filter" aria-hidden="true"></i>
Also, the right way to use FontAwesome in React in documented here: https://fontawesome.com/how-to-use/on-the-web/using-with/react
answered Nov 10 at 13:48
Davo
41437
41437
dont work className too class also works n .. doesnt work its points outside src
– Tested
Nov 10 at 13:51
Can you share your project structure? The path to your CSS is wrong. Usingclass
would work but throw an error in React sinceclass is a reserved word in ES6+
, so always useclassName
.
– Davo
Nov 10 at 13:58
classname too doesnt apply FontAwesome. Ihave update my code
– Tested
Nov 10 at 14:01
According to your file structure, and assuming yourindex.js
file is in thesrc
folder too:import './styles/fontawesome/css/fontawesome.min.css';
– Davo
Nov 10 at 14:04
ya everything is in src as outside it doesnt support i have edited question
– Tested
Nov 10 at 14:12
|
show 3 more comments
dont work className too class also works n .. doesnt work its points outside src
– Tested
Nov 10 at 13:51
Can you share your project structure? The path to your CSS is wrong. Usingclass
would work but throw an error in React sinceclass is a reserved word in ES6+
, so always useclassName
.
– Davo
Nov 10 at 13:58
classname too doesnt apply FontAwesome. Ihave update my code
– Tested
Nov 10 at 14:01
According to your file structure, and assuming yourindex.js
file is in thesrc
folder too:import './styles/fontawesome/css/fontawesome.min.css';
– Davo
Nov 10 at 14:04
ya everything is in src as outside it doesnt support i have edited question
– Tested
Nov 10 at 14:12
dont work className too class also works n .. doesnt work its points outside src
– Tested
Nov 10 at 13:51
dont work className too class also works n .. doesnt work its points outside src
– Tested
Nov 10 at 13:51
Can you share your project structure? The path to your CSS is wrong. Using
class
would work but throw an error in React since class is a reserved word in ES6+
, so always use className
.– Davo
Nov 10 at 13:58
Can you share your project structure? The path to your CSS is wrong. Using
class
would work but throw an error in React since class is a reserved word in ES6+
, so always use className
.– Davo
Nov 10 at 13:58
classname too doesnt apply FontAwesome. Ihave update my code
– Tested
Nov 10 at 14:01
classname too doesnt apply FontAwesome. Ihave update my code
– Tested
Nov 10 at 14:01
According to your file structure, and assuming your
index.js
file is in the src
folder too: import './styles/fontawesome/css/fontawesome.min.css';
– Davo
Nov 10 at 14:04
According to your file structure, and assuming your
index.js
file is in the src
folder too: import './styles/fontawesome/css/fontawesome.min.css';
– Davo
Nov 10 at 14:04
ya everything is in src as outside it doesnt support i have edited question
– Tested
Nov 10 at 14:12
ya everything is in src as outside it doesnt support i have edited question
– Tested
Nov 10 at 14:12
|
show 3 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239552%2ffont-awesome-icons-are-not-displaying-react%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password