I. Emergence of Problems:
- , in the previous project development, the error occurred when applying
male-components
, applying injectGlobal
to define style variables, and injectGlobal 'is not exported from' application-components '
. Ii. Analysis and Solution of problems:
The reason for
- problem is that
The injectGlobal API was removed and removed by createGlobalStyle in styled-components v4.
API is removed and replaced by malt-components v4. Replaced with createGlobalStyle
the new API
appears as a style component and is introduced as a label based on the style component idea. InjectGlobal cannot be applied directly as the original injectGlobal
. We define a global style variable that will be inserted into the document as a component. Solution: The first step is to define the global style with createGlobalStyle
and wrap the global style in it. Wrap the CSS
style with the back-quotation string, as shown below:
import { createGlobalStyle } from 'styled-components'
export const Globalstyle = createGlobalStyle`
body{
margin: 0;
padding: 0
}`
The second step is to import the style in the project main file. The code is as follows:
import { Globalstyle } from './style'
The third step is introduced as a label in the form of a style component, as shown below:
class App extends Component {
render () {
return (
<Fragment>
<GlobalStyled/>
</Fragment>
)
}
}
Read More:
- When react dynamically prunes components by operating arrays, the state of the remaining components is not preserved. Solution to the problem (method of dynamically setting unique key value)
- Error: ‘default’ is not exported by node_ modules/qs/lib/ index.js
- Tainted canvases may not be exported
- Could not create connection to database server. Attempted reconnect 3 times. Giving
- Higher order components in react
- [flash] error: “necessary system components are not working properly, please repair Adobe Flash Player” and error ා 2046
- Solution to the incomplete display of the principle icon number exported by smartpdf in Ad
- Solve the problem of showing unregistered (unknown custom element) when importing components into Ant Design Pro
- An import error is reported in the python. The solution to setting. Pylintrc is invalid
- Elememt UI introduces components on demand to report errors
- Ambari shield big data components
- pip Import Error:cannot import Name main solution
- Visual SVN server provider failed to perform the attempted operation 0x80041024 after win7 upgraded win10
- WSL 2 needs to update its kernel components
- Python failed to read TIF file exported by envi.
- Import error, failed to import the debug version of PYD
- Finally solved the importError: DLLload failed: the specified module could not be found when import matplotlib.pyplot
- Uniapp uses CMD to import uview. An error is reported, and the file search fails: ‘uview UI’‘
- sqoop-import ERROR tool.ImportTool: Import failed: No primary key could be found for table user_info
- [Solved] Import Echars5.0 Error: “export ‘default‘ (imported as ‘echarts‘) was not found in ‘echarts‘